3

I have the following nginx location blocks:

location /publish/domain.io.php {
  allow 127.0.0.1;
  deny all;
}

location ~\.php {
  try_files $uri =404;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_intercept_errors on;
  fastcgi_pass 127.0.0.1:9000;
  include /etc/nginx/fastcgi_params;
}

The problem is that the location block /publish/domain.io.php does not seem to be executing. I can call the php script domain.io.php from any host.

Ideas? Thanks much.

5

Use the = location prefix to determine exact match. As it is written in nginx documentation: "If an exact match is found, the search terminates."

So, your location should look like:

location = /publish/domain.io.php {
  allow 127.0.0.1;
  deny all;              # Gives 403
}

or

location = /publish/domain.io.php {
  internal;              # Gives 404
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.