-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Proxying with nginx
You'll need the latest version of nginx (preferably something starting with 1.3.15 or 16; at the time of the writing of this page version 1.4.1 is the current stable).
To install the latest nginx you can go about 2 ways
- build it from source
- get a packaged-for-your-distro option (personal favorite)
Both options are document on the nginx wiki.
Enough with the intro stuff; now for the fun part. The part below can also be found on the and on the page nginx pages, but for me it actually worked with noVNC (and I was so happy I decided to document it real quick).
In nginx you need 2 items in your config:
- Upstream IP + port to the websocketproxy.py server
upstream vnc_proxy {
server 127.0.0.1:29876;
}
- A path to your base URL, where you want it to show up.
server {
listen 80;
server_name example.com;
<other_config>
location /vncws/ {
proxy_pass http://one_vnc;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
<other_config>
}
- You'll also need to add the noVNC HTML + JS code somewhere, and make it point to example.com/vncws/. I've put the noVNC HTML/JS code at example.com/vnc/. The **/vnc/**folder folder looks like this:
- images folder
- include folder
- vnc.html or vnc_auto.html . I've used vnc_auto.html, but I had to provide it some special URL like /vnc/vnc_auto.html?host=example.com/vncws/&port=80&path=?token=vnc_token . This is used in OpenNebula, with another tool updating the tokens into the target folder that is handled by websocketproxy.py
Regarding the last method, I'll admit, it's somewhat not-very-general-and-more-custom. The first 2 steps should be general enough to help proxy the websocket part of noVNC through nginx [in fact, that's what's mostly needed]. Point 3. depends on how you use the HTML + JS code.