Monday, July 25, 2016

Nginx location blocks factcgi php inheritance issue

Leave a Comment

I have a configuration file which reads a little like the below.

I have a mediawiki installation under the subfolder /wiki/ represented by its location block. I then have a default location / which serves the main part of the site. I have an embedded .php catch in the /wiki/ location block which seems to work. However, I have a legacy requirement in the default .php block to auto_prepend a file.

When making calls to /wiki/ this file is loaded. I presume because nginx is somehow falling into that block. Can someone explain whats wrong here?

I suppose I could ignore the /wiki/ with regex in the default .php block. But fishing for some other ideas.

Many thanks

  server {   listen *:80;    server_name           www.somesite.com   error_page 404 /404error.html;    index  index.php;    if ($http_x_forwarded_proto = "http") {         return 301 https://www.street-crime.com$request_uri;   }    location @extensionless-php {     internal;       rewrite ^(.*)$ $1.php last;   }    location ^~ /wiki {     index index.html index.htm index.php;     root  /var/www/html/somesite/current;     try_files $uri $uri /wiki/index.php?query_string;          location ~ /wiki/(.*\.php)$ {                 include /etc/nginx/fastcgi_params;                 fastcgi_pass  127.0.0.1:9000;                 fastcgi_connect_timeout 3m;                 fastcgi_read_timeout 3m;                 fastcgi_send_timeout 3m;         }   }    location @missing {      root          /var/www/html/somesite/current;     include       /etc/nginx/fastcgi_params;     try_files     /bootstrap/routes.php =404;      fastcgi_pass  127.0.0.1:9000;     fastcgi_param PHP_VALUE   auto_prepend_file="/var/www/html/somesite/current/includes/boot.php";     fastcgi_param SCRIPT_FILENAME $document_root/bootstrap/routes.php;     fastcgi_connect_timeout 3m;     fastcgi_read_timeout 3m;     fastcgi_send_timeout 3m;   }    location ~ \.php$ {      root          /var/www/html/somesite/current;     include       /etc/nginx/fastcgi_params;     try_files     $uri @missing;      fastcgi_pass  127.0.0.1:9000;     fastcgi_param PHP_VALUE auto_prepend_file="/var/www/html/somesite/current/includes/boot.php";     fastcgi_connect_timeout 3m;     fastcgi_read_timeout 3m;     fastcgi_send_timeout 3m;   } } 

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment