Nginx/Fcgi: index.php issue with pseudo-alias location -


nginx 1.6.2 on debian jessie

i want map example.com/forum/ requests /path/to/htdocs/phpbb , cut off /forum/ part in uri. on stackoverflow recommended "rewrite" solution instead of "alias", because there bugs.

server {     listen [::]:80;     server_name example.com;     root /var/www/html;      index index.php index.html;     #try_files $uri $uri/ =404;      location /forum/     {         root /path/to/htdocs/phpbb;         rewrite ^/forum/(.*)$ /$1 break;          location ~ .+\.php$         {             rewrite ^/forum/(.*)$ /$1 break;             include snippets/fastcgi-php.conf;             fastcgi_pass unix:/var/run/php5-fpm.sock;         }     } } 

the example configuration works fine – example.com/forum/viewtopic.php executes script /path/to/htdocs/phpbb/viewtopic.phpexample.com/ (index.php) doesn't work:

"/var/www/html/index.php" failed (2: no such file or directory)

after removing "index" line server block:

directory index of "/path/to/htdocs/phpbb/" forbidden

after moving "index" and/or "try_files" line(s) location block:

index.php served without passing on php-fpm…

ok, what's wrong config? hints?

ok, alias buggy (rewrite too…), if avoid try_files , use if instead (even if evil…) should work!

server {     listen [::]:80;     server_name example.com;     root /var/www/html;      location /forum/     {         alias /path/to/htdocs/phpbb/;         index index.php index.html;          location ~ "^(/forum/)(.+\.php)(/.+){0,1}$"         {             if (!-f $document_root$2)             {                 return 404;             }              fastcgi_index index.php;             include fastcgi.conf;              fastcgi_param  script_filename    $document_root$2;             fastcgi_param  script_name        $1$2;             fastcgi_param  path_info          $3;              fastcgi_pass unix:/var/run/php5-fpm.sock;         }     } } 

phpinfo() looks fine, 1 question remains: is secure?


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -