Merge branch '3.3.x'

This commit is contained in:
Marc Alexander 2020-01-27 19:49:01 +01:00
commit 0bbe959fbd
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 106 additions and 121 deletions

View file

@ -1,119 +1,95 @@
# Sample nginx configuration file for phpBB. # Sample nginx configuration file for phpBB.
# Global settings have been removed, copy them # Tested with:
# from your system's nginx.conf. # - nginx 0.8.35
# Tested with nginx 0.8.35. # - nginx 1.17.7 (mainline)
#
# Filename: /etc/nginx/sites-available/example.com.conf
#
# Replace example.com with your own domain name.
http { # Sample FastCGI server configuration.
# Compression - requires gzip and gzip static modules. # Filename: /etc/nginx/conf.d/php.conf
gzip on; #
gzip_static on; # upstream php {
gzip_vary on; # server unix:/run/php-fpm/php-fpm.sock;
gzip_http_version 1.1; # }
gzip_min_length 700;
# Compression levels over 6 do not give an appreciable improvement # Remove www domain prefix.
# in compression ratio, but take more resources. server {
gzip_comp_level 6; listen 80;
# IPv6
listen [::]:80;
# IE 6 and lower do not support gzip with Vary correctly. # Remove www
gzip_disable "msie6"; server_name www.example.com;
# Before nginx 0.7.63: return 301 $scheme://example.com$request_uri;
#gzip_disable "MSIE [1-6]\."; }
# Catch-all server for requests to invalid hosts. # Board configuration.
# Also catches vulnerability scanners probing IP addresses. server {
server { listen 80;
# default specifies that this block is to be used when # IPv6
# no other block matches. listen [::]:80;
listen 80 default; server_name example.com;
root /path/to/phpbb;
server_name bogus;
return 444; # phpBB uses index.htm
root /var/empty; index index.php index.html index.htm;
}
# Loggers
# If you have domains with and without www prefix, error_log /var/log/nginx/example.com.error.log warn;
# redirect one to the other. access_log /var/log/nginx/example.com.access.log;
server {
# Default port is 80. location / {
#listen 80; try_files $uri $uri/ @rewriteapp;
server_name myforums.com; # Pass the php scripts to FastCGI server specified in upstream declaration.
location ~ \.php(/|$) {
# A trick from http://wiki.nginx.org/Pitfalls#Taxing_Rewrites: include fastcgi.conf;
return 301 http://www.myforums.com$request_uri; fastcgi_split_path_info ^(.+\.php)(/.*)$;
} fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
# The actual board domain. fastcgi_param DOCUMENT_ROOT $realpath_root;
server { try_files $uri $uri/ /app.php$is_args$args;
#listen 80; fastcgi_pass php;
server_name www.myforums.com; }
root /path/to/phpbb; # Deny access to internal phpbb files.
location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) {
location / { deny all;
# phpBB uses index.htm # deny was ignored before 0.8.40 for connections over IPv6.
index index.php index.html index.htm; # Use internal directive to prohibit access on older versions.
try_files $uri $uri/ @rewriteapp; internal;
} }
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last; location @rewriteapp {
} rewrite ^(.*)$ /app.php/$1 last;
}
# Deny access to internal phpbb files.
location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) { # Correctly pass scripts for installer
deny all; location /install/ {
# deny was ignored before 0.8.40 for connections over IPv6. try_files $uri $uri/ @rewrite_installapp =404;
# Use internal directive to prohibit access on older versions.
internal; # Pass the php scripts to fastcgi server specified in upstream declaration.
} location ~ \.php(/|$) {
include fastcgi.conf;
# Pass the php scripts to fastcgi server specified in upstream declaration. fastcgi_split_path_info ^(.+\.php)(/.*)$;
location ~ \.php(/|$) { fastcgi_param PATH_INFO $fastcgi_path_info;
# Unmodified fastcgi_params from nginx distribution. fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params; fastcgi_param DOCUMENT_ROOT $realpath_root;
# Necessary for php. try_files $uri $uri/ /install/app.php$is_args$args =404;
fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_pass php;
fastcgi_param PATH_INFO $fastcgi_path_info; }
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; }
fastcgi_param DOCUMENT_ROOT $realpath_root;
try_files $uri $uri/ /app.php$is_args$args; location @rewrite_installapp {
fastcgi_pass php; rewrite ^(.*)$ /install/app.php/$1 last;
} }
# Correctly pass scripts for installer # Deny access to version control system directories.
location /install/ { location ~ /\.svn|/\.git {
# phpBB uses index.htm deny all;
try_files $uri $uri/ @rewrite_installapp =404; internal;
}
# Pass the php scripts to fastcgi server specified in upstream declaration.
location ~ \.php(/|$) {
# Unmodified fastcgi_params from nginx distribution.
include fastcgi_params;
# Necessary for php.
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
try_files $uri $uri/ /install/app.php$is_args$args =404;
fastcgi_pass php;
}
}
location @rewrite_installapp {
rewrite ^(.*)$ /install/app.php/$1 last;
}
# Deny access to version control system directories.
location ~ /\.svn|/\.git {
deny all;
internal;
}
}
# If running php as fastcgi, specify php upstream.
upstream php {
server unix:/tmp/php.sock;
}
} }

View file

@ -22,6 +22,7 @@ PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB")
NGINX_SITE_CONF="/etc/nginx/sites-enabled/default" NGINX_SITE_CONF="/etc/nginx/sites-enabled/default"
NGINX_CONF="/etc/nginx/nginx.conf" NGINX_CONF="/etc/nginx/nginx.conf"
APP_SOCK=$(realpath "$DIR")/php-app.sock APP_SOCK=$(realpath "$DIR")/php-app.sock
NGINX_PHP_CONF="$DIR/nginx-php.conf"
# php-fpm # php-fpm
PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm" PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm"
@ -45,13 +46,21 @@ sudo $PHP_FPM_BIN \
--fpm-config "$DIR/php-fpm.conf" --fpm-config "$DIR/php-fpm.conf"
# nginx # nginx
cat $DIR/../phpBB/docs/nginx.sample.conf \
| sed "s/root \/path\/to\/phpbb/root $(echo $PHPBB_ROOT_PATH | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/g" \
| sed -e '1,/The actual board domain/d' \
| sed -e '/If running php as fastcgi/,$d' \
| sed -e "s/fastcgi_pass php;/fastcgi_pass unix:$(echo $APP_SOCK | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g');/g" \
| sed -e 's/#listen 80/listen 80/' \
| sudo tee $NGINX_SITE_CONF
sudo sed -i "s/user www-data;/user $USER;/g" $NGINX_CONF sudo sed -i "s/user www-data;/user $USER;/g" $NGINX_CONF
sudo cp "$DIR/../phpBB/docs/nginx.sample.conf" "$NGINX_SITE_CONF"
sudo sed -i \
-e "s/example\.com/localhost/g" \
-e "s|root /path/to/phpbb;|root $PHPBB_ROOT_PATH;|g" \
$NGINX_SITE_CONF
# Generate FastCGI configuration for Nginx
echo "
upstream php {
server unix:$APP_SOCK;
}
" > $NGINX_PHP_CONF
sudo mv "$NGINX_PHP_CONF" /etc/nginx/conf.d/php.conf
sudo nginx -T
sudo service nginx start sudo service nginx start