nginx how to serve a simple index.html file on server location

Viewed 14

On my current nginx configuration, I'm serving an react app on port 5000 and api on 3000. I need to serve one extra index.html file on a specific location, but I can't get it to work.

nginx

server {

        root /var/www/html;

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

   server_name example.website.com;


    location / { #react app
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    location /graphql { #api
        proxy_pass http://localhost:4000/graphql;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
    #Add html page here
    location /myhtml {
        root /var/www/html;
    }
#....

I placed the index.html file in /var/www/html directory

The idea is to get that html page when I access https://example.website.com/myhtml Currently, it displays a 404 not found nginx info

0 Answers
Related