/etc/systemd/system/wstunnel.service
:[Unit]
Description=WSTunnel listening WebSocket locally at 31337
After=network.target
[Service]
User=nobody
ExecStart=/usr/local/bin/wstunnel -v --server [ws://127.0.0](wss://127.0.0.0/).1:31337
Restart=on-failure
#AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
sudo systemctl enable wstunnel
sudo systemctl start wstunnel
www.google.com {
tls /etc/v2ray/v2ray.crt /etc/v2ray/v2ray.key
reverse_proxy / 127.0.0.1:31337
}
server {
listen 80;
listen 443 ssl;
server_name www.google.com;
location /wstunnel {
if ($http_upgrade != "websocket") { # Do something when WebSocket upgrading negotiation fails
return 301 <https://www.google.com>;
}
proxy_pass <http://127.0.0.1:31337>;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
# Show real IP
proxy_set_header X-Real-IP $remote_addr;
}
ssl_certificate /etc/v2ray/v2ray.crt
ssl_certificate_key /etc/v2ray/v2ray.key
}