nginx-Deploy nginx and refresh the page with 404 not found

Problem Description:

1. After deploying using Nginx , the login page will display 404 after refreshing.

2. After configuring the page access IP and port number exposed by the front end, the access report is 404

server {
        listen       21060;
        server_name  localhost;
 
        location / {
            root   html/dist;
            index  index.html index.htm;
        }
        location /gateway/ {
             rewrite ^/gateway/(.*) /$1 break;
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X-Forwarded-Proto $scheme;
             proxy_connect_timeout 5;
             proxy_pass http://x.x.x.x:port/;
    }

1.Complete try_files $uri $uri/ /dist/project/index.html,

Specify the detailed index under the root directory. html access path

2. Improve root html/dist/project attributes;

Our front-end code has another layer of folders in dist. Could it be that it was not found? It’s quite strange.

After improvement, nginx can access the front-end service normally.

Guess you like

Origin blog.csdn.net/qq_44691484/article/details/126354457