Hi,

I'm currently using the following to block access to a vhost from non-whitelisted domains:
Code:
location / {
                index index.html index.htm index.php;
                satisfy any;
                allow x.x.x.x; # My IP
                deny all;


                # Enable gzip compression
                gzip_static on;


                }
However, this only blocks directories. Directly requesting a file (e.g. /index.php) still works. I found that I was supposed to use location ^~ / { - however, when I use this it does indeed give a 403 for the non-whitelisted IPs, but it also breaks for whitelisted domains. When I do this, PHP-scripts are no longer passed to PHP-FPM, causing nginx to download the actual php files instead of serving it properly.

How should I handle this?
My PHP-FPM block:
Code:
location ~ \.php$ {
        # Important, don't remove for security reasons
        try_files $uri =404;


        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/vhost.com/public_html$fastcgi_script_name;
        fastcgi_pass unix:/var/run/nginx/php-fpm-vhost.sock;
}
Thanks in advance,