From 27e95864a8d3d05bc85578880a567422ead96b22 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 5 Nov 2015 16:55:19 +0100 Subject: [PATCH 1/3] [ticket/14271] Update sample config PHPBB3-14271 --- phpBB/docs/nginx.sample.conf | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf index c82f5c8e49..6c701b0218 100644 --- a/phpBB/docs/nginx.sample.conf +++ b/phpBB/docs/nginx.sample.conf @@ -61,9 +61,17 @@ http { root /path/to/phpbb; + # strip app.php/ prefix if it is present + rewrite ^/app\.php/?(.*)$ /$1 permanent; + location / { # phpbb uses index.htm index index.php index.html index.htm; + try_files $uri @rewriteapp; + } + + location @rewriteapp { + rewrite ^(.*)$ /app.php/$1 last; } # Deny access to internal phpbb files. @@ -76,11 +84,12 @@ http { # Pass the php scripts to fastcgi server specified in upstream declaration. location ~ \.php$ { - fastcgi_pass php; - # Necessary for php. - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Unmodified fastcgi_params from nginx distribution. include fastcgi_params; + # Necessary for php. + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + fastcgi_pass php; } # Deny access to version control system directories. From b27be0b8574f770d3a5aa0299be7d3c3fea744f4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 8 Nov 2015 11:02:37 +0100 Subject: [PATCH 2/3] [ticket/14271] Improve try_files and use split path info PHPBB3-14271 --- phpBB/docs/nginx.sample.conf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf index 6c701b0218..8b5fa6aa7b 100644 --- a/phpBB/docs/nginx.sample.conf +++ b/phpBB/docs/nginx.sample.conf @@ -83,11 +83,13 @@ http { } # Pass the php scripts to fastcgi server specified in upstream declaration. - location ~ \.php$ { + location ~ \.php { # Unmodified fastcgi_params from nginx distribution. include fastcgi_params; # Necessary for php. - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_param PATHINFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; fastcgi_pass php; } From 966c34d0ad4b64cbf5b35c815c310f24e68224fc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 9 Nov 2015 10:08:52 +0100 Subject: [PATCH 3/3] [ticket/14271] Properly use try_files in nginx sample config PHPBB3-14271 --- phpBB/docs/nginx.sample.conf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/phpBB/docs/nginx.sample.conf b/phpBB/docs/nginx.sample.conf index 8b5fa6aa7b..2ead3552fd 100644 --- a/phpBB/docs/nginx.sample.conf +++ b/phpBB/docs/nginx.sample.conf @@ -61,13 +61,10 @@ http { root /path/to/phpbb; - # strip app.php/ prefix if it is present - rewrite ^/app\.php/?(.*)$ /$1 permanent; - location / { # phpbb uses index.htm index index.php index.html index.htm; - try_files $uri @rewriteapp; + try_files $uri $uri/ @rewriteapp; } location @rewriteapp { @@ -83,14 +80,15 @@ http { } # Pass the php scripts to fastcgi server specified in upstream declaration. - location ~ \.php { + location ~ \.php(/|$) { # Unmodified fastcgi_params from nginx distribution. include fastcgi_params; # Necessary for php. fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_param PATHINFO $fastcgi_path_info; + 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; }