2
第一次與nginx
。
我有一個的WebSocket的NodeJS服務器偵聽的ws://service_name:3600
。
我使用docker-compose
:nginx的WS無效的網址前綴
version: "2"
services:
# stuff
service_name:
image: imagename
ports:
- 3600:3600
links:
# stuff
- proxy
proxy:
image: image-from-nginx-with-custom-config
ports:
- 80:80
- 443:443
- 8443:8443
我的配置:
// stuff
server {
listen 8443;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/certs/crt.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;
keepalive_timeout 60;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
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 https;
location/{
proxy_pass ws://service_name:3600;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
我得到nginx: [emerg] invalid URL prefix in /etc/nginx/conf.d/default.conf
在啓動時。
所以nginx的不承認ws
,我該怎麼辦?
的可能的複製[Nginx的無效地址前綴(HTTPS的網頁套接字://計算器.com/questions/32992908/nginx-invalid-url-prefix) –
在nginx中,你仍然需要爲你的url使用http。 'proxy_pass http:// service_name:3600;' –
@TarunLalwani我試過這樣做,但它似乎並沒有工作。我可能在我的配置有錯誤... – andr