Eu tenho navegador e servidor no endereço ip a.b.c.d
Agora eu tenho 2 URLs possíveis para o servidor:
-
Por meio do Nginx do navegador
browser -> https://a.b.c.d/ -> server
-
Através do WSS do javascript
browser -> wss://a.b.c.d:10062 -> server
Então, listnes de servidores em 443 (nginx) e algum outro aplicativo em 10062.
Eu quero mudar segunda conexão para a mesma porta (443):
browser -> wss://a.b.c.d/someurl -> server
Então é possível fazer proxy no nginx para a.b.c.d: 10062, algo assim:
server {
listen 80;
listen 443 ssl;
ssl_certificate /path/to/crt/for/https;
ssl_certificate_key /path/to/key/for/https;
server_name a.b.c.d;
location /someurl {
-->> What to write here to create redirect for wss://a.b.c.d:10062 ? << --
}
# the other locations here ('/', etc)
# ...
# ...
}
Eu tentei em seguida:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
location /someurl {
proxy_pass http://127.0.0.1:10062;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
Mas quando for para o link para teste, mostra
2015/12/14 16:12:51 [error] 371#0: *113 connect() failed (111: Connection refused)
while connecting to upstream, client: my_ip, server: a.b.c.d, request: "GET /someurl HTTP/1.1",
upstream: "http://127.0.0.1:10062/someurl", host: "a.b.c.d"
MAS !: Netstat mostra isso:
sudo netstat -tnlp | grep :10062
tcp 0 0 a.b.c.d:10062 0.0.0.0:* LISTEN 5702/webrtc2sip
Então parece que eu preciso especificar a.b.c.d ao invés de 127.0.0.1, então eu tentei
location /someurl {
proxy_pass http://a.b.c.d:10062;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
Resultado:
2015/12/14 16:54:11 [error] 13189#0: *123 recv() failed (104: Connection reset by peer)
while reading response header from upstream,
client: my_ip, server: a.b.c.d, request: "GET /someurl HTTP/1.1", upstream: "http://a.b.c.d:10062/someurl", host: "a.b.c.d"
Ok. Eu trunketed someurl ao passar para proxy:
location = /someurl {
return 302 /someurl/;
}
location /someurl/ {
proxy_pass http://a.b.c.d:10062/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
Agora, quando vou para o link ou link , mostra:
2015/12/14 17:14:45 [error] 15836#0: *70 recv() failed (104: Connection reset by peer)
while reading response header from upstream, client: my_ip, server: a.b.c.d, request: "GET /someurl/ HTTP/1.1", upstream: "http://a.b.c.d:10062/", host: "a.b.c.d"
Por que mostra o envio de dados: " link "? Não deveria mostrar "wss: //a.b.c.d: 10062 /"?