websockets-rs / rust-websocket

A WebSocket (RFC6455) library written in Rust
http://websockets-rs.github.io/rust-websocket/
MIT License
1.55k stars 223 forks source link

HTTP proxy #158

Open 1tgr opened 6 years ago

1tgr commented 6 years ago

Can I use the client to connect via an HTTP proxy? e.g. in a corporate environment direct connections aren't possible.

kellerkindt commented 5 years ago

You can, but you need to update your proxy settings. I am using it behind an nginx server with the following configuration needed:

nginx.conf

http {
# ...
        map $http_upgrade $connection_upgrade {
                default upgrade;
                '' close;
        }
}

sites-enabled/default

server {
# ...
                location /websocket {
                        proxy_pass http://TARGET_IP:TARGET_PORT/TARGET_URI;
                        proxy_http_version 1.1;
                        proxy_set_header Upgrade $http_upgrade;
                        proxy_set_header Connection "Upgrade";
                        proxy_connect_timeout 7d;
                        proxy_read_timeout 7d;
                        proxy_send_timeout 7d;
                }
}
1tgr commented 5 years ago

Thanks, I was looking to use a proxy from the client, ie to connect out to the internet via the HTTP CONNECT verb.

vi commented 5 years ago

@1tgr For this you can use rust-websocket with custom underlying connection.

1tgr commented 5 years ago

Indeed, that's what I'm doing.

timvisee commented 5 years ago

@1tgr Could you provide an example for what you're currently using to connect through an HTTP proxy?

igitur commented 3 years ago

@1tgr Could you provide an example for what you're currently using to connect through an HTTP proxy?

FYI, Tim needs to know this so that he can improve his awesome ffsend tool. He's just too humble to say it himself.