无法访问我的网站

无法访问我的网站

大家好!我是 Linux 爱好者,在 Debian VPS 上使用 nginx 时遇到了问题。直到最近我才能访问我的静态网站,但现在却无法访问了。

这是我的用户sites-available/exampleexample

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))

答案1

从评论中可以看出:nginx 仅在端口 80 上监听,但 OP 正尝试通过端口 443 上的 https 访问该站点。

运行certbot --nginx向 nginx 添加了必要的配置,以便监听端口 443。

相关内容