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 reload,确定

你能帮助我吗?

答案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这是我的服务器配置的关键点。

相关内容