解决vue打包后部署到线上nginx后刷新页面会404的问题

RT,主要还是nginx配置文件的问题,特此上一个较全的配置信息供大家参考:

server
{
    listen 80;
    server_name www.xxx.com;
    location / {
        root /home/www/box_admin_html;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
        proxy_next_upstream http_500 http_502 http_504 error timeout;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,PUT,OPTIONS,DELETE';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        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;
    }
    access_log /home/wwwlogs/access.log;

}

posted @ 2022-05-14 12:38  童年的回忆  阅读(299)  评论(0编辑  收藏  举报
如果本博客解决了您的问题,可以微信支付宝打赏鼓励一下作者哦,在此表示感谢