因此,当我尝试点击http://mayall.syniq.co.uk时,nginx 给了我一个 403 Forbidden 错误页面,该页面应该向 Rik Mayall 吐出一个致敬页面,http: //byrne.syniq.co 也是如此。英国(应该不会花很长时间猜出我的命名方案:))。
namei -l /www/vhosts/mayall.syniq.co.uk/public/index.html 产生以下结果:
f: /www/vhosts/mayall.syniq.co.uk/public/index.html
drwxr-xr-x root root /
drwxr-xr-x www-data www-data www
drwxr-xr-x www-data www-data vhosts
drwxr-xr-x www-data www-data mayall.syniq.co.uk
drwxr-xr-x www-data www-data public
-rw-r--r-- www-data www-data index.html
Run Code Online (Sandbox Code Playgroud)
所以这不是权限。我的虚拟主机配置如下:
server {
listen *:80;
listen [::]:80;
server_name mayall.syniq.co.uk;
# Character Set
charset utf-8;
# Logs
access_log /www/vhosts/mayall.syniq.co.uk/logs/access_log.nginx;
error_log /www/vhosts/mayall.syniq.co.uk/logs/error_log.nginx;
# Directory Indexes
index index.html index.htm;
root /www/vhosts/mayall.syniq.co.uk/public;
location / {
try_files $uri $uri/ =404;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
# Block access to .htaccess
location ~ \.ht {
deny all;
}
}
Run Code Online (Sandbox Code Playgroud)
这是日志中显示的内容:
2014/10/01 18:58:20 [error] 20957#0: *1 access forbidden by rule, client: 31.49.162.112, server: mayall.syniq.co.uk, request: "GET / HTTP/1.1", host: "mayall.syniq.co.uk"
2014/10/01 18:58:30 [error] 20957#0: *1 access forbidden by rule, client: 31.49.162.112, server: mayall.syniq.co.uk, request: "GET /index.html HTTP/1.1", host: "mayall.syniq.co.uk"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
所以,freenode 上#nginx 中的一个人为我指出了这一点,但我猜他不想在这里发布答案。
我得到 403 的原因是因为location ~ \.ht
块匹配.ht
in index.html
,因此错误地正确阻止了请求。
修复只是/
在 . 如下:
location ~ /\.ht {
deny all;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10624 次 |
最近记录: |