Nginx

無法訪問我的網站

  • December 7, 2021

每個人!我是 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。

引用自:https://serverfault.com/questions/1085607