REST URLs and NGINX (config help needed)

Edho Arief me at myconan.net
Tue Jun 14 18:09:13 UTC 2016


Hi

On Wed, Jun 15, 2016, at 02:28, Ben wrote:
> Hi,
> 
> Based on scraps found in the NGINX docs, I have a semi-working config 
> that looks as follows :
> 
> #####
> 	location /demo {
> 		allow 10.0.0.0/8;
> 		deny all;
> 		try_files $uri @pdemo;
> 	}
> 	location @pdemo {
> 		fastcgi_param SCRIPT_FILENAME /path/to/demo.php;
> 		fastcgi_param SCRIPT_NAME /demo.php;
> 		fastcgi_param  PATH_INFO        $fastcgi_path_info;
> 		fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
> 		fastcgi_param QUERY_STRING    $args;
> 		include fastcgi_params;
> 	}
> 
> #####
> 
> 
> I say this config is "semi-working" because :
> 
> A base-call to http://example.com/demo returns the hello-world output 
> from my PHP router. No problems there.
> 
> But, if I call, say, http://example.com/demo/hello/x, the PHP router 
> doesn't match the route (despite expecting hello/x as the path).
> 
> If it helps, I'm using bramus router and my configured paths are as 
> follows :
> 

Looks like the logic for getting base path is a bit interesting. Try
this for related line:

fastcgi_param SCRIPT_NAME /demo/;



More information about the nginx mailing list