Separate the front-end and back-end and use nginx as the proxy server. Refresh the page and report 404. Solution

Situation one

Add a sentence to the nginx configuration file. The effect is that when the nginx agent cannot find the page, it will try to access the specified page. For the front-end vue project, the page happens to be managed by vue itself, so no error will be reported.

location /{
                alias /var/www/html/;
                index index.html abc.html;

                try_files $uri $uri/ /index.html;
        }

Case 2 plus try_files refresh is still 404, you need to spell the requested prefix in front of the html accessed by try_files

        location /work {
                alias /var/www/html/;
                index index.html abc.html;

               # try_files $uri $uri/ /index.html;

               try_files $uri $uri/ /work/index.html;
        }

Guess you like

Origin blog.csdn.net/lxctxx/article/details/131400344