Need To Run Multiple Location Blocks

Edho Arief edho at myconan.net
Tue Jul 17 08:29:46 UTC 2012


On Tue, Jul 17, 2012 at 10:42 AM, justin <nginx-forum at nginx.us> wrote:
> I have the following location blocks:
>
>   location ^~ /publish {
>       allow 127.0.0.1;
>
>       #Allow home
>       allow 99.100.101.102;
>
>       deny all;
>     }
>
> Then the following location block to process PHP after:
>
>     location ~\.php {
>       try_files $uri =404;
>       fastcgi_index index.php;
>       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>       fastcgi_intercept_errors on;
>       fastcgi_pass 127.0.0.1:9000;
>       include /etc/nginx/fastcgi_params;
>     }
>
> The problem is that a request to /publish/execute.php is only hitting
> the first location block, and not hitting the fastcgi PHP execution
> location block. How can I make the publish location block also check for
> PHP files and if so, execute them according to the second location
> block?
>

Put another \.php$ block inside the /publish block.

location ^~ /publish/ {
  ...
  location ~ \.php$ {
    ...
  }
}



More information about the nginx mailing list