Nginx 404 not found. What am I missing?

I tried this setting.

but, I got 404 not found error.

I want to know the reason why this is not working.

services = {
    nginx = {
      enable = true;
      virtualHosts."_" = {
        locations = {
          "/" = {
        root = "/var/www/index.html";
          };
        };
      };
#      config = pkgs.lib.readFile /root/nginx.conf;
    };
};

/nix/store/4mfg0w5yl9hcyvyi01p6y0zsg34x4gqy-nginx.conf

user nginx nginx;
error_log stderr;
daemon off;
events {
}
http {
        include /nix/store/zhg107mpadyv441dx1a7way26z315ng4-nginx-1.16.1/conf/mime.types;
        include /nix/store/zhg107mpadyv441dx1a7way26z315ng4-nginx-1.16.1/conf/fastcgi.conf;
        include /nix/store/zhg107mpadyv441dx1a7way26z315ng4-nginx-1.16.1/conf/uwsgi_params;
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers EECDH+aRSA+AESGCM:EDH+aRSA:EECDH+aRSA:+AES256:+AES128:+SHA1:!CAMELLIA:!SEED:!3DES:!DES:!RC4:!eNULL;
        # $connection_upgrade is used for websocket proxying
        map $http_upgrade $connection_upgrade {
                default upgrade;
                ''      close;
        }
        client_max_body_size 10m;
        server_tokens off;
        server {
                listen 0.0.0.0:80 ;
                listen [::]:80 ;
                server_name _ ;
                location / {
                        root /var/www/index.html;
                }
        }
}

and, There is a file on /var/www/index.html.

As far as I remember the root has to be a folder.

1 Like

Thank you very much !!