【问题标题】:Nginx 404 on static html file静态 html 文件上的 Nginx 404
【发布时间】:2019-08-29 13:07:50
【问题描述】:

我已经在 ubuntu 18.04 上安装了 nginx,但我无法提供纯 html 文件,因为一切都只是给我一个 404 错误。

这是我的 nginx.conf(未修改):

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

events {
        worker_connections 768;
        # multi_accept on;
}

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; # 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/*;
}

我的默认文件:

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /andreas/www;

        index index.html index.htm index.nginx-debian.html app.js;

        server_name _;

        location / {
                try_files $uri $uri.html $uri/ =404;
        }
}

Nginx 访问日志显示如下:

"GET /index.html HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

【问题讨论】:

    标签: ubuntu nginx ubuntu-18.04


    【解决方案1】:

    终于发现“root”设置为错误的文件夹,正确更新后一切正常。

    【讨论】:

      猜你喜欢
      • 2014-06-07
      • 2017-06-05
      • 2015-12-01
      • 2016-08-19
      • 2015-02-26
      • 2021-01-12
      • 2023-02-18
      • 1970-01-01
      • 2016-09-24
      相关资源
      最近更新 更多