解决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 @   童年的回忆  阅读(301)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 张高兴的大模型开发实战:(一)使用 Selenium 进行网页爬虫
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
如果本博客解决了您的问题,可以微信支付宝打赏鼓励一下作者哦,在此表示感谢
点击右上角即可分享
微信分享提示