目前我的配置文件(/etc/nginx/sites-available/default)如下:
但我仍然可以通过example.com/credentials.js从Web访问credentials.js。有什么建议吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location /credentials.js {
deny all;
return 404;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
}
但我仍然可以通过example.com/credentials.js从Web访问credentials.js。有什么建议吗?
/credential.js
块移动到location /
里面再试一次吗? - Tarun Lalwaninginx -T
命令并将输出提供给您的问题。 - Tarun Lalwani