Add a Nginx reverse proxy to combine all the used ports into one single port
This will allow this web UI to sit nicely behind a reverse proxy. Dynamically set the ports used for the - VNC service - noVNC service - Pulseaudio socket - VNC audio transport websocket Remove all mentions of the above used ports in the Dockerfile.
This commit is contained in:
@@ -102,14 +102,14 @@ index cb6a9fd..4d599e1 100644
|
||||
UI.rfb.focus();
|
||||
+
|
||||
+ let audio_url;
|
||||
+ let host = window.location.hostname;
|
||||
+ let port = 32123;
|
||||
+ // let host = window.location.hostname;
|
||||
+ // let port = '<PORT_AUDIO_WEBSOCKET>';
|
||||
+ if (window.location.protocol === "https:") {
|
||||
+ audio_url = 'wss';
|
||||
+ } else {
|
||||
+ audio_url = 'ws';
|
||||
+ }
|
||||
+ audio_url += '://' + host + ':' + port;
|
||||
+ audio_url += '://' + window.location.host + '/audiowebsock';
|
||||
+
|
||||
+ UI.webaudio = new WebAudio(audio_url);
|
||||
+ UI.toggleAudio();
|
||||
@@ -326,14 +326,14 @@ index 8e2f5cb..d3cf6ab 100644
|
||||
// successfully connected to a server
|
||||
function connectedToServer(e) {
|
||||
+ let audio_url;
|
||||
+ let host = window.location.hostname;
|
||||
+ let port = 32123;
|
||||
+ // let host = window.location.hostname;
|
||||
+ // let port = '<PORT_AUDIO_WEBSOCKET>';
|
||||
+ if (window.location.protocol === "https:") {
|
||||
+ audio_url = 'wss';
|
||||
+ } else {
|
||||
+ audio_url = 'ws';
|
||||
+ }
|
||||
+ audio_url += '://' + host + ':' + port;
|
||||
+ audio_url += '://' + window.location.host + '/audiowebsock';
|
||||
+
|
||||
+ wa = new WebAudio(audio_url);
|
||||
+ document.getElementById('toggleAudioButton').style.display = "block";
|
||||
@@ -360,7 +360,7 @@ index 8e2f5cb..d3cf6ab 100644
|
||||
+ if (wa.connected) {
|
||||
+ console.log('Stopping audio...')
|
||||
+ wa.stop();
|
||||
+ document.getElementById('toggleAudioButton').innerText = "Enable Audio (requires access to port 32123)";
|
||||
+ document.getElementById('toggleAudioButton').innerText = "Enable Audio";
|
||||
+ } else {
|
||||
+ console.log('Starting audio websocket on: ' + audio_url)
|
||||
+ wa.start();
|
||||
@@ -410,7 +410,7 @@ index 8e2f5cb..d3cf6ab 100644
|
||||
|
||||
<body>
|
||||
<div id="top_bar">
|
||||
+ <div id="toggleAudioButton">Enable Audio (requires access to port 32123)</div>
|
||||
+ <div id="toggleAudioButton">Enable Audio</div>
|
||||
<div id="status">Loading</div>
|
||||
<div id="sendCtrlAltDelButton">Send CtrlAltDel</div>
|
||||
</div>
|
||||
|
||||
40
overlay/opt/noVNC/nginx.conf
Normal file
40
overlay/opt/noVNC/nginx.conf
Normal file
@@ -0,0 +1,40 @@
|
||||
daemon off;
|
||||
worker_processes auto;
|
||||
pid /tmp/vncproxy.pid;
|
||||
error_log /home/<USER>/.cache/log/vncproxy.err.log;
|
||||
|
||||
events {
|
||||
}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen <PORT_NOVNC_WEB> default_server;
|
||||
|
||||
access_log /home/<USER>/.cache/log/vncproxy.log;
|
||||
client_body_temp_path /tmp/client_body;
|
||||
fastcgi_temp_path /tmp/fastcgi_temp;
|
||||
proxy_temp_path /tmp/proxy_temp;
|
||||
scgi_temp_path /tmp/scgi_temp;
|
||||
uwsgi_temp_path /tmp/uwsgi_temp;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:<PORT_NOVNC_SERVICE>/;
|
||||
}
|
||||
|
||||
location /websockify {
|
||||
proxy_pass http://127.0.0.1:<PORT_NOVNC_SERVICE>/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /audiowebsock {
|
||||
proxy_pass http://127.0.0.1:<PORT_AUDIO_WEBSOCKET>/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user