一、Nginx配置
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream ws {
server localhost:8081;
server localhost:8082;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
二、webpack配置
const proxys = [
{
option: {
target: 'http://localhost:8081/',
changeOrigin: true,
ws: true,
secure: false
}
}
]