aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2020-01-27 19:45:15 +0100
committerMarc Alexander <admin@m-a-styles.de>2020-01-27 19:45:15 +0100
commitd2a344af5d5314835a8792a9aed580637824a0b2 (patch)
tree1998b810416916d949934418fac8bc45192188ca
parentMerge branch '3.2.x' into 3.3.x (diff)
parent[ticket/16313] Remove http block from sample Nginx configuration file (diff)
downloadphpbb-d2a344af5d5314835a8792a9aed580637824a0b2.tar.gz
phpbb-d2a344af5d5314835a8792a9aed580637824a0b2.tar.bz2
phpbb-d2a344af5d5314835a8792a9aed580637824a0b2.zip
Merge pull request #5825 from AlfredoRamos/ticket/16313
[ticket/16313] Remove http block from sample Nginx configuration file
-rw-r--r--phpBB/docs/nginx.sample.conf206
-rwxr-xr-xtravis/setup-webserver.sh23
2 files changed, 107 insertions, 122 deletions
diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf
index c5a9472a1c..25363ad34d 100644
--- a/phpBB/docs/nginx.sample.conf
+++ b/phpBB/docs/nginx.sample.conf
@@ -1,7 +1,11 @@
# Sample nginx configuration file for phpBB.
-# Global settings have been removed, copy them
-# from your system's nginx.conf.
-# Tested with 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.
# If you want to use the X-Accel-Redirect feature,
# add the following to your config.php.
@@ -11,117 +15,89 @@
# See http://wiki.nginx.org/XSendfile for the details
# on X-Accel-Redirect.
-http {
- # Compression - requires gzip and gzip static modules.
- gzip on;
- gzip_static on;
- gzip_vary on;
- gzip_http_version 1.1;
- gzip_min_length 700;
-
- # Compression levels over 6 do not give an appreciable improvement
- # in compression ratio, but take more resources.
- gzip_comp_level 6;
-
- # IE 6 and lower do not support gzip with Vary correctly.
- gzip_disable "msie6";
- # Before nginx 0.7.63:
- #gzip_disable "MSIE [1-6]\.";
-
- # Catch-all server for requests to invalid hosts.
- # Also catches vulnerability scanners probing IP addresses.
- server {
- # default specifies that this block is to be used when
- # no other block matches.
- listen 80 default;
-
- server_name bogus;
- return 444;
- root /var/empty;
- }
-
- # If you have domains with and without www prefix,
- # redirect one to the other.
- server {
- # Default port is 80.
- #listen 80;
-
- server_name myforums.com;
-
- # A trick from http://wiki.nginx.org/Pitfalls#Taxing_Rewrites:
- return 301 http://www.myforums.com$request_uri;
- }
-
- # The actual board domain.
- server {
- #listen 80;
- server_name www.myforums.com;
-
- root /path/to/phpbb;
-
- location / {
- # phpBB uses index.htm
- index index.php index.html index.htm;
- try_files $uri $uri/ @rewriteapp;
- }
-
- 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) {
- deny all;
- # deny was ignored before 0.8.40 for connections over IPv6.
- # Use internal directive to prohibit access on older versions.
- 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/ /app.php$is_args$args;
- fastcgi_pass php;
- }
-
- # Correctly pass scripts for installer
- location /install/ {
- # phpBB uses index.htm
- try_files $uri $uri/ @rewrite_installapp =404;
-
- # 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;
- }
- }
+# Sample FastCGI server configuration.
+# Filename: /etc/nginx/conf.d/php.conf
+#
+# upstream php {
+# server unix:/run/php-fpm/php-fpm.sock;
+# }
+
+# Remove www domain prefix.
+server {
+ listen 80;
+ # IPv6
+ listen [::]:80;
+
+ # Remove www
+ server_name www.example.com;
+ return 301 $scheme://example.com$request_uri;
+}
- # If running php as fastcgi, specify php upstream.
- upstream php {
- server unix:/tmp/php.sock;
- }
+# Board configuration.
+server {
+ listen 80;
+ # IPv6
+ listen [::]:80;
+ server_name example.com;
+ root /path/to/phpbb;
+
+ # phpBB uses index.htm
+ index index.php index.html index.htm;
+
+ # Loggers
+ error_log /var/log/nginx/example.com.error.log warn;
+ access_log /var/log/nginx/example.com.access.log;
+
+ location / {
+ try_files $uri $uri/ @rewriteapp;
+
+ # Pass the php scripts to FastCGI server specified in upstream declaration.
+ location ~ \.php(/|$) {
+ include fastcgi.conf;
+ 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/ /app.php$is_args$args;
+ fastcgi_pass php;
+ }
+
+ # Deny access to internal phpbb files.
+ location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) {
+ deny all;
+ # deny was ignored before 0.8.40 for connections over IPv6.
+ # Use internal directive to prohibit access on older versions.
+ internal;
+ }
+ }
+
+ location @rewriteapp {
+ rewrite ^(.*)$ /app.php/$1 last;
+ }
+
+ # Correctly pass scripts for installer
+ location /install/ {
+ try_files $uri $uri/ @rewrite_installapp =404;
+
+ # Pass the php scripts to fastcgi server specified in upstream declaration.
+ location ~ \.php(/|$) {
+ include fastcgi.conf;
+ 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;
+ }
}
diff --git a/travis/setup-webserver.sh b/travis/setup-webserver.sh
index fd87d97449..68bcd6ac00 100755
--- a/travis/setup-webserver.sh
+++ b/travis/setup-webserver.sh
@@ -22,6 +22,7 @@ PHPBB_ROOT_PATH=$(realpath "$DIR/../phpBB")
NGINX_SITE_CONF="/etc/nginx/sites-enabled/default"
NGINX_CONF="/etc/nginx/nginx.conf"
APP_SOCK=$(realpath "$DIR")/php-app.sock
+NGINX_PHP_CONF="$DIR/nginx-php.conf"
# 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"
# 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 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