This is my configuration of the subdomain dev.mypage.com:
server {
listen 80;
server_name dev.mypage.com;
root /home/user/web/dev;
index index.html index.htm index.php;
access_log /home/user/logs/dev/access.log;
error_log /home/user/logs/dev/error.log;
location / {
try_files $uri $uri/ /index.html;
allow xxx.xxx.xxx.xxx;
deny all;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm/dev.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
I want to forbid access to all of the files and subdirs under / except for me (xxx.xxx.xxx.xxx).
Running this config and
- accessing dev.mypage.com with other IP turns into a 403 error.
- accessing dev.mypage.com/subdir with other IP turns into a 403 error.
- accessing dev.mypage.com/index.php with other IP returns the page.
- accessing dev.mypage.com/subdir/index.php with other IP returns the page.
So the cases 3 and 4 are not working as expected. I had assumed that
location / {}
would mean all files and directories. What do I have to do to block all other IPs for all contents in this subdomain?