haz*_*rot 11 nginx websocket docker reactjs ws
这是问题......当我在本地启动 React 应用程序时 npm start 。我没有连接失败。
如果我在 Docker 容器中启动 NGINX 和 React 服务器,我会不断得到
WebSocketClient.js:16 WebSocket 连接到“ws://localhost:3000/ws”失败:
默认配置文件
upstream client {
server client:3000;
}
upstream api {
server api:5000;
}
server {
listen 80;
location / {
proxy_pass http://client;
}
location /ws {
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /api {
rewrite /api/(.*) /$1 break;
proxy_pass http://api;
}
}
Run Code Online (Sandbox Code Playgroud)
小智 22
将其添加到 .env:
WDS_SOCKET_PORT=0
Run Code Online (Sandbox Code Playgroud)
请参阅此问题以获取更多说明和信息:https://github.com/facebook/create-react-app/issues/11897
归档时间: |
|
查看次数: |
29177 次 |
最近记录: |