V
V
Vitaly2019-08-23 14:04:34
Nginx
Vitaly, 2019-08-23 14:04:34

Why is nginx not returning the html file?

For some reason, the example from the Internet does not work for me.
I use nginx to proxy local web services.
Now I just need to render a static html page.
I decided to implement it directly through NGINX, but in response 404.
Here is part of the config file:

server {
        listen 443 ssl;

        server_name myserver.com;

        ssl_certificate /etc/...;
        ssl_certificate_key /etc/...; 

        location / {
            return 301 https://google.com;
        }

       location /privacy-policies/ { # так не работает
           root /home/user/privacy_policys;
        }

       location / {  # так тоже не работает
           root  /home/user/privacy_policys;
           index  index.html index.htm;
        }


    location /first_service/ {
        proxy_pass http://localhost:3001;
        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 /ssecond_service/ {
        proxy_pass http://localhost:3002;
        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;
        }
}

The static HTML in the folder /home/user/privacy_policyscalled it index.htmland policy.html
Through the proxy everything works.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-08-23
@Scorpiored88

nginx.org/ru/docs/http/ngx_http_core_module.html#alias

location /privacy-policies/ {
    alias  /home/user/privacy_policies/;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question