0

In my nginx error log is the following message:

FastCGI sent in stderr: "Unable to open primary script: /www//vb/showthread.php

My site is not made with vb and so I want to deny any requests to /vb/ how can I do that?
I experimented with

location /vb/ { deny all; } 

but I still see many such errors in my error log, it looks like spam requests.

How can I also prevent access to /wp-loging.php and such?

I find the double // in the error log strange and I can't understand it.

here's my server config:

server { listen 80; server_name www.domain.com; #charset koi8-r; #access_log logs/nattiq.access.log main; location / { root /home/www; index index.php; try_files $uri @rewrite; } location //vb/showthread.php { deny all; } location /wp-login.php { deny all; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /home/www; proxy_http_version 1.1; proxy_set_header Connection ""; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location @rewrite { rewrite ^ /index.php; 

}

 location ~ \.php$ { root /home/www; # fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params; fastcgi_read_timeout 150; 
2
  • You should update your question and add your nginx server configuration. Commented Mar 10, 2016 at 12:53
  • something like :location ~ ^/download/(.*)$ { worked but I get access forbidden by rule in the logs. any better way? Commented Mar 10, 2016 at 13:58

1 Answer 1

0

The double // is because of SCRIPT_FILENAME, which should actually look like this:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

Rather that trying to block individual .php files that do not exist, you should prevent any fake .php file from being transmitted upstream by the addition of one line at the top of the location ~ \.php$ block:

try_files $uri =404; 

See this document for details.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.