nginx 現在是 404 Not Found

nginx 現在是 404 Not Found

我以前有nginx,但現在網路上是404。也許某些東西會重新啟動,但我不確定。

404 Not Found
nginx/1.18.0 (Ubuntu)

我搜尋了nginx的各種錯誤。 sudo nginx -t 就可以了。

/var/log/nginx/error.log

[notice] 60852#60852: signal process started

捲曲-Ihttps://test.com

HTTP1.1 404 Not Found
Server: nginx/1.18.0 (Ununtu)
Date: Thu, 27 Aug 21:02:56 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive

/etc/nginx/sites-available/test.conf

server {
listen 80;
listen [::]:80;
root /var/www/html/test.com/public;
index index.php index.html index.htm;
server_name test.com www.test.com;

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}

include /var/www/html/test.com/.nginx.conf;

# new lines
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/test.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

/etc/nginx/nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
}

http {

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip on;


    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}



sudo服務nginx重新加載,ok

你能幫助我嗎?

答案1

404 Not Found」表示系統無法在 Web 伺服器上找到特定資源。所以問題出在伺服器。那麼,明天再試一次。

答案2

一些基於 Ngnix 的虛擬伺服器需要精確的 IP 位址。通過這個很容易檢查:

curl http://myvirtualdomain.com 
  <-- return 404 error
curl -vk https://myvirtualdomain.com 
  <-- OK

這是由nginx配置引起的。

在虛擬伺服器區塊上新增伺服器的 IP 位址:

server {
listen 80;
listen [::]:80;
root /var/www/html/test.com/public;
index index.php index.html index.htm;
server_name test.com www.test.com;

listen 10x.32.22.xx;   # adds your server ip 

這是我的nginx伺服器配置的一個關鍵點。

相關內容