2

I have a pretty typical php5-fpm setup like so:

location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/home/gfd-dev/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } 

and I just want to just block 1 file by ip address, but then php doesn't run

location ^~ /script_to_hide.php { allow 100.100.100.100; deny all; } 

Do I put the whole php$ params in both or is there a another way to do this to just tell php to run?

1 Answer 1

2

nginx.conf

location ~ \.php$ { include fastcgi_params; } location ^~ /secret_functions/ { allow 100.100.100.100; deny all; include fastcgi_params; } 

fastcgi_params

 ... fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/home/gfd-dev/var/run/php5-fpm.sock; fastcgi_index index.php; 

P.S.

Nginx iterate through each location based on the following logic:

location = / { [ configuration A ] } location / { [ configuration B ] } location /documents/ { [ configuration C ] } location ^~ /images/ { [ configuration D ] } location ~* \.(gif|jpg|jpeg)$ { [ configuration E ] } 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @mikhailov, I was able to do this also, but what I think I'm trying to figure out is if I have to do this every time I want to make a directive, do I have to put in the php bit, it can get pretty cluttered if I just keep copying and pasting the same bit of code. Is there some sort of inclution way to write it? or might a directory be better at allowing the .php to run?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.