Skip to content

Proxying with nginx

s00ner edited this page Mar 28, 2016 · 14 revisions

Install Nginx

You'll need a version of Nginx capable of proxying websocket traffic. Anything 1.3 or newer should work.

To install the latest Nginx you can either:

  • build it from source
  • get a packaged-for-your-distro option

Both options are documented on the nginx wiki.

###Configure Nginx In Nginx you need 3 items in your config:

  1. Upstream IP + port to the websocketproxy.py server

    This is not strictly necessary but it makes the configuration more readable. You could also explicitly specify the server in your proxy_pass parameters.

    upstream vnc_proxy {
        server 127.0.0.1:6080;
    }
    
  2. A path to /websockify to proxy the websocket connection.

    server {
        listen 80;
        server_name example.com;
        <other_config>
        location /websockify {
              proxy_http_version 1.1;
              proxy_pass http://vnc_proxy/;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
        }
    
  3. A path to your base URL, where you want it to show up.

        location /vncws/ {
              proxy_pass http://vnc_proxy/;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
        }
    
        <other_config>
    }
    

With this config, you can point your browser to http://example.com/vncws/vnc.html to use NoVNC. This configuration also works fine with https instead.

Clone this wiki locally