VUE项目打包后posy代理失效Nginx解决

阅读 43

2022-03-30

vue项目打包dist部署Nginx

Vueproxy代理失效Nginx解决办法

vue.config.js

 devServer: {
  proxy: {
            "/oauth2": {
                target: 'http://localhost:12911/oauth2/',
                secure: false,
                changeOrigin: true,
                pathRewrite: {
                    '^/oauth2': 'http://localhost:12911/oauth2/'
                },
            },
        },
     }

Nginx.conf

location /oauth2/ {
            proxy_pass http://localhost:12911/oauth2/;
			proxy_redirect off;
			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_connect_timeout 90;
			proxy_max_temp_file_size 0;
            index  index.html index.htm;
			access_log  logs/oauth2-auth.access.log;
			error_log  logs/oauth2-auth.error.log debug;
			
        }

精彩评论(0)

0 0 举报