Set nginx.conf to deny all connections except to certain files or directories
- by Ben
I am trying to set up Nginx so that all connections to my numeric ip are denied, with the exception of a few arbitrary directories and files. So if someone goes to my IP, they are allowed to access the index.php file, and the phpmyadmin directory for example, but should they try to access any other directories, they will be denied.
This is my server block from nginx.conf:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/http/nginx/$fastcgi_script_name;
include fastcgi_params;
}
}
How would I proceed? Thanks very much!