如何将nginx指向my index.html位置?

如何将nginx指向my index.html位置?,nginx,http-status-code-404,Nginx,Http Status Code 404,我正在尝试使用nginx设置测试服务器块。我尝试了很多方法,但是test.myserver.com总是向我展示404。我的目标是在/var/www/test/html/index.html中显示index.html 这就是我到目前为止所做的: server { listen 80; listen [::]:80; # SSL configuration # listen 443 ssl; liste

我正在尝试使用nginx设置测试服务器块。我尝试了很多方法,但是test.myserver.com总是向我展示404。我的目标是在/var/www/test/html/index.html中显示index.html

这就是我到目前为止所做的:

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

        # SSL configuration
        #
        listen 443 ssl;
        listen [::]:443 ssl;


        root /var/www/test;
        index index.html index.htm index.nginx-debian.html;
        server_name test.myserver.com www.test.myserver.com;

        location ^~ /html {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files index.html $uri $uri/ / =404;
        }

        location / {
                index /html/index.html;
        }
正如你所看到的,我已经在尝试不同的方法了。我从中了解到^~文件夹的位置


那么:为什么nginx给了我404,我该如何修复它呢?

所以我最终发现我的默认服务器块配置出了问题。基本上,由于我不知道的原因,我先前存在的nextcloud实例似乎已经接管作为默认服务器。仅此一项可能做不了多少,但是/etc/nginx/conf.d/nextcloud.conf文件将nextcloud设置为默认服务器,集成/etc/nginx/sites enabled中所述的其他服务器块,并将nextcloud服务器块运行时使用的相同标记添加到它们。一旦我从/etc/nginx/conf.d/nextcloud.conf内的test.myserver.com服务器块中删除了一大堆不必要的
location~
location/
标记(在站点可用版本中没有),一切都开始正常工作。

为什么不设置
root/var/www/test/html;
,因为这似乎是正确的文档根目录?