每个人!我是 linux 爱好者,我对 debian VPS 上的 nginx 有疑问。直到最近我可以访问我的静态网站,但现在我不能。
这是我的用户名sites-available/example
在哪里example
:
server {
listen 80 ;
listen [::]:80 ;
server_name example.com ;
root /var/www/example ;
index index.html index.htm index.nginx-debian.html ;
location / {
try_files $uri $uri/ =404 ;
}
}
sites-available/example
有符号链接sites-enabled
我的nginx/error.log
:
2021/12/07 08:57:02 [notice] 7383#7383: signal process started
2021/12/07 09:22:00 [notice] 2195#2195: signal process started
在signal process started
我遇到 403 或 404 错误之前:
2021/12/05 17:53:05 [emerg] 12400#12400: open() "/etc/nginx/sites-enabled/mail" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2021/12/05 17:55:01 [emerg] 12415#12415: open() "/etc/nginx/sites-enabled/mail" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2021/12/05 18:02:33 [emerg] 12468#12468: open() "/etc/nginx/sites-enabled/mail" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2021/12/05 18:05:15 [error] 12522#12522: *1 directory index of "/var/www/mail/" is forbidden, client: 212.16.10.194, server: mail.example.com, request: "GET / HTTP/1.1", host: "example.com"
2021/12/05 18:07:45 [error] 12562#12562: *1 directory index of "/var/www/mail/" is forbidden, client: 212.16.10.194, server: mail.example.com, request: "GET / HTTP/1.1", host: "example.com"
我什至重新安装了 nginx,但我仍然无法访问我的网站。我应该怎么做或在哪里搜索信息来解决这个问题?
sudo ss -tnlp|grep :80
显示了这一点:
LISTEN 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=2524,fd=6),("nginx",pid=2522,fd=6))
LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=2524,fd=7),("nginx",pid=2522,fd=7))
来自评论: nginx 仅在端口 80 上侦听,但 OP 试图通过端口 443 上的 https 访问该站点。
运行
certbot --nginx
向 nginx 添加了必要的配置以侦听端口 443。