静态HTML文件上的Nginx 404

时间:2019-08-29 13:07:50

标签: ubuntu nginx ubuntu-18.04

我已在ubuntu 18.04上安装了nginx,但由于所有内容都给我一个404错误,因此我无法提供纯HTML文件。

这是我的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

1 个答案:

答案 0 :(得分:0)

最后,正确地更新后,发现“根”设置为不正确的文件夹。