novnc nginx websock转发
2019-03-19 本文已影响0人
daos
最近遇到一个问题使用novnc转发服务器,但是vnc服务端不想暴露到外部,所以使用nginx做了一层代理转发,只把需要的访问接口转发到外网。novnc使用wss协议连接到服务器的,wss是基于http或者https基础实现。
1.流程
web端novnc---->内网vnc服务器对应端口
修改后流程为
web端novnc---->代理服务器端口---->内网vnc服务器对应端口
2.具体代理服务器配置如下
server {
listen 29877; #代理的接口给novnc使用
server_name xxx.com;
access_log /data/wwwlogs/vnc_nginx.log combined;
location / {
proxy_pass http://10.1.1.1:29876;#内网的vnc服务器及端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 1d;
proxy_send_timeout 1d;
proxy_read_timeout 1d;
}
#如果原始的novnc是使用ssl传输的话这里需要把vnc服务器上面对应证书拿过来配置否则不成功
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/server.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/server.key;
}
3.扩展阅读
websock介绍:https://zh.wikipedia.org/wiki/WebSocket
知乎上关于websocket的回答:https://www.zhihu.com/question/20215561/answer/40316953
novnc:https://github.com/novnc/novnc