# Sunstone's vnc not working behind nginx reverse proxy

**URL:** <https://forum.opennebula.io/t/sunstones-vnc-not-working-behind-nginx-reverse-proxy/6183>\
**Category:** Product Support\
**Created:** [July 20, 2018, 7:33am UTC](https://forum.opennebula.io/t/sunstones-vnc-not-working-behind-nginx-reverse-proxy/6183 "2018-07-20T07:33:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bjornskau](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bjornskau](https://forum.opennebula.io/u/bjornskau)\
**Post date:** [July 20, 2018, 7:33am UTC](https://forum.opennebula.io/t/sunstones-vnc-not-working-behind-nginx-reverse-proxy/6183/1 "2018-07-20T07:33:31Z")

</div>

Hi guys! I am new to opennebula. I have two node setup: sunstone is living in a small vm, and hypervisor is placed on dedicated bare-metal server with CentOS 7. I have setup nginx as reverse proxy for sunstone one the same vm. I am getting “VNC Server disconnected (code: 1006)” error. Here is my configuration:

/etc/nginx/conf.d/opennebula.conf:

```
upstream sunstone {
        server 127.0.0.1:9869;
}

upstream vnc_proxy {
        server 127.0.0.1:29876; 
}

server {
        listen 80;
        server_name 10.xx.xx.xx;

        ### Permanent redirect to HTTPS (optional)
        return 301 https://$server_name:443;
}

server {
        listen 443 ssl;
        server_name 10.xx.xx.xx;
        ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
        ssl_certificate_key /etc/ssl/nginx-selfsigned.key;

        ### Proxy requests to upstream
        location / {
                 proxy_pass http://sunstone;
        }
  

  location /websockify {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-Server $host;
          proxy_set_header x-forwarded-proto $scheme;
          proxy_set_header Host $host;
          proxy_http_version 1.1;
          proxy_read_timeout 86400;
          proxy_pass https://vnc_proxy;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
        }
}

```

/etc/oned/sunstone-server.conf:

```
:tmpdir: /var/tmp
:one_xmlrpc: http://localhost:2633/RPC2
:host: 127.0.0.1
:port: 9869
:sessions: memory
memcache_host: localhost
:memcache_port: 11211
:memcache_namespace: opennebula.sunstone
:env: 'prod'
:debug_level: 3
:auth: opennebula
:core_auth: cipher
:remote_version: http://downloads.opennebula.org/latest
:vnc_proxy_port: 29876
:vnc_proxy_support_wss: yes
:vnc_proxy_cert: /etc/one/certs/one-tornasol.crt
:vnc_proxy_key: /etc/one/certs/one-tornasol.key
:vnc_proxy_ipv6: false
:vnc_request_password: false
:lang: en_US
:table_order: desc
:marketplace_url: http://marketplace.opennebula.systems/
:oneflow_server: http://localhost:2474/
:routes:
    - oneflow
    - vcenter
    - support

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![VURoland](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vuroland/32/7682_2.png) [@VURoland](https://forum.opennebula.io/u/VURoland)\
**Post date:** [July 23, 2018, 11:35pm UTC](https://forum.opennebula.io/t/sunstones-vnc-not-working-behind-nginx-reverse-proxy/6183/2 "2018-07-23T23:35:51Z")

</div>

I notice the cert-name, is it really selfsigned?  
If so, check this post:

> [@VNC noVNC ready: native WebSockets, canvas rendering](https://forum.opennebula.io/t/vnc-novnc-ready-native-websockets-canvas-rendering/5511/2):
>
> I managed to get this working a few days ago. Steps I followed: generate self-signed certificates (or get real ones) set the group on cert and key to oneadmin or the websocket proxy wont read them (check logs) configure nginx https and reverse proxy https to sunstone port 9869 configure nginx to redirect http to https configure sunstone-server.conf to use wss only, setup certificate paths open firewall for http, https and wss/vnc (80,443,29876) These are the things I had trouble with: chec…

hope this helps!

---

<div class="post-metadata">

**Author:** ![bjornskau](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bjornskau](https://forum.opennebula.io/u/bjornskau)\
**Post date:** [July 24, 2018, 6:43am UTC](https://forum.opennebula.io/t/sunstones-vnc-not-working-behind-nginx-reverse-proxy/6183/3 "2018-07-24T06:43:32Z")

</div>

Hi! 10x for your answer. I’ll try it out this week!) I did almostly the same things, but I could do some mistakes. I’ll double check it.)

---

<div class="post-metadata">

**Author:** ![bjornskau](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bjornskau](https://forum.opennebula.io/u/bjornskau)\
**Post date:** [July 30, 2018, 11:50am UTC](https://forum.opennebula.io/t/sunstones-vnc-not-working-behind-nginx-reverse-proxy/6183/4 "2018-07-30T11:50:08Z")

</div>

HI! Finally I solved this issue: here is

**nginx.conf**

```
upstream sunstone {
    server 127.0.0.1:9869;
}

upstream vnc_proxy {
    server 127.0.0.1:29876; 
}

server {
    listen 80;
    server_name 10.xx.xx.xx;

    ### Permanent redirect to HTTPS (optional)
    return 301 https://$server_name:443;
}

server {
    listen 443 ssl;
    server_name 10.xx.xx.xx;
    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    ### Proxy requests to upstream
    location / {
             proxy_pass http://sunstone;
    }
  

  location /websockify {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header x-forwarded-proto $scheme;
      proxy_set_header Host $host;
      proxy_http_version 1.1;
      proxy_read_timeout 86400;
      proxy_pass https://vnc_proxy;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }
}

```

**sunstone-server.conf**

```
:tmpdir: /var/tmp
:one_xmlrpc: http://localhost:2633/RPC2
:one_xmlrpc_timeout: 60
:host: 127.0.0.1
:port: 9869
:sessions: memory
:memcache_host: localhost
:memcache_port: 11211
:memcache_namespace: opennebula.sunstone
:env: 'prod'
:debug_level: 3
:auth: opennebula
:core_auth: cipher
:remote_version: http://downloads.opennebula.org/latest
:vnc_proxy_port: 29876
:vnc_proxy_support_wss: only
:vnc_proxy_cert: /etc/one/ssl/nginx.crt
:vnc_proxy_key: /etc/one/ssl/nginx.key
:vnc_proxy_ipv6: false
:vnc_request_password: false
:keep_me_logged: true
:lang: en_US
:table_order: desc
:mode: 'mixed'
:marketplace_url: http://marketplace.opennebula.systems/
:oneflow_server: http://localhost:2474/
:routes:
- oneflow
- vcenter
- support
```
