I have a console app that runs on a few machines. I can access it using a websocket client by entering the URL ws://192.168.1.152/h264/
. I need to be able to establish connections to these machines externally. I have tried many options in Nginx. I would like to be able to connect to ws://streams.mydomain.com/101
and have it go to the IP above. Here is a table of examples.
ws://streams.mydomain.com/152/
> ws://192.168.1.152
ws://streams.mydomain.com/153/
> ws://192.168.1.153
ws://streams.mydomain.com/154/
> ws://192.168.1.154
I have tried various options including the following:
Method 1
http {
server {
listen *;
server_name streams.mydomain.com;
location /101/ {
proxy_pass $scheme://192.168.1.52;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
}
This method results in "Invalid response" (gets a 301 and expects a 101)
Method 2
http {
server {
listen *;
server_name streams.mydomain.com;
location /101/ {
add_header 'Connection' 'Upgrade';
add_header 'Upgrade' websocket;
return 101 $scheme://192.168.1.52;
}
}
}
This results in "Missing upgrade header".
Other methods
I also tried using the stream
directive with no luck as well as rewrite
under HTTP, also with varying success.
I posted a question about the second method specifically, but I'm hoping that this question will open up answers for methods I haven't been able to find.
Here is a pastebin of the FULL config: https://pastebin.com/1H49n5LB
0 Answers