Roman Bogachev
Roman Bogachev

Reputation: 1

Secure WSS via NGINX Proxy

I`m using OpenNebula. When I try to proxy traffic to a secure connection, there is a problem with the proxy of the websocket.

I tried WebSocket proxying

nginx.conf

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}     

default_server.conf

upstream sunstone {
    server 127.0.0.1:9869;
}

upstream websocketproxy {
    server 127.0.0.1:29876;
}

server {
    listen *:80;
    server_name example.com;
    rewrite ^(.*)$ https://example.com$1 permanent;
}

server {
    listen 443 ssl http2 deferred;
    ssl on;
    ssl_session_timeout 24h;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    access_log  /var/log/nginx/opennebula-sunstone-access.log;
    error_log  /var/log/nginx/opennebula-sunstone-error.log;

    client_max_body_size 1G;

    location / {
        proxy_pass http://sunstone;
        proxy_redirect     off;
        log_not_found      off;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_set_header   X-Forwarded-FOR $proxy_add_x_forwarded_for;
    }

    location /websockify {
        proxy_pass http://websocketproxy;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

When I try to open VNC console - get those errors.

Msg: noVNC ready: native WebSockets, canvas rendering
VM1479:37 WebSocket connection to 'wss://example.com:29876/?token=azy36gz3k4ibsuxsphwg' failed: Error in connection establishment: net::ERR_CONNECTION_RESET
WebSocket on-error event
WebSocket on-close event
Msg: Server disconnected (code: 1006)

In OpenNebula sunstone-server.conf set the next:

:vnc_proxy_port: 29876
:vnc_proxy_support_wss: yes
:vnc_proxy_cert: /etc/letsencrypt/live/example.com/fullchain.pem;
:vnc_proxy_key: /etc/letsencrypt/live/example.com/privkey.pem
:vnc_proxy_ipv6: false
:vnc_request_password: false

How I can forward encrypt wss?

Upvotes: 0

Views: 1794

Answers (0)

Related Questions