更改默认值后重新启动时 Nginx 未知文件

Nginx Unkown File when restarting after changing default

我想将我的博客设置为指向 yourdomainanme/blog 并在默认 yourdomainname.com 上托管静态页面。我更改了路径,但由于某种原因它没有找到 html 文件。

错误

    nginx: [emerg] unknown directive "home" in /etc/nginx/sites-enabled/default:14
    nginx: configuration file /etc/nginx/nginx.conf test failed

我的默认文件

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name yourdomain.com; # Replace with your domain

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 10G;

    location / {
        root var/www/;
        home home.html;
    }

    location /blog {
        proxy_pass http://localhost:2368;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
    } 
}

我相信您将不存在的 home 关键字与 index 关键字混淆了,后者告诉 NGINX 根目录中的 'default' 或 'index' 文件。

location / {
    root var/www/;
    home home.html;
}

应该是

location / {
    root var/www/;
    index home.html;
}