0
点赞
收藏
分享

微信扫一扫

nginx部署vue配置文件

老北京的热干面 2022-02-17 阅读 151
server {
        listen       40004;


        access_log  /usr/local/service/nginxaccess.log ;

		#这是部署在   domain.com/a/b路径下  
		#vue打包需要设置 vue.conf.js中的 publicPath 否则资源会404
        location /a/b/ {
            alias  /usr/local/xxx/dist/;
            try_files $uri $uri/ /index.html; #此处解决刷新页面出现404的问题
            index  /index.html;
        }
        #根域名下
 		location / {
            alias  /usr/local/xxx/dist;
            try_files $uri $uri/ /index.html; #此处解决刷新页面出现404的问题
            index  /index.html;
        }
        
        location ^~/cloud/gateway/ {
            root   html;
            index  index.html index.htm index.jsp;
            proxy_pass  http://127.0.0.1:8080/;
            proxy_set_header Host  $http_host;
            proxy_set_header Cookie $http_cookie;
            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;
            client_max_body_size  100m;
        }

}

举报

相关推荐

0 条评论