Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #622: Make noVNC can be accessed via URLs like https://example.com/novnc #623

Merged
merged 6 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ARG DEBIAN_FRONTEND="noninteractive"
ARG DEBCONF_NONINTERACTIVE_SEEN="true"

RUN set -eu && \

Check failure on line 10 in Dockerfile

View workflow job for this annotation

GitHub Actions / Test / shellcheck

SC2035 info: Use ./*glob* or -- *glob* so names with dashes won't become options.
apt-get update && \
apt-get --no-install-recommends -y install \
tini \
Expand All @@ -34,6 +34,7 @@
tar -xf /tmp/novnc.tar.gz -C /tmp/ && \
cd "/tmp/noVNC-${VERSION_VNC}" && \
mv app core vendor package.json *.html /usr/share/novnc && \
sed -i "s|UI\.initSetting('path', 'websockify')|UI.initSetting('path', window.location.pathname.replace(/[^/]*$/, '').substring(1) + 'websockify')|" /usr/share/novnc/app/ui.js && \
unlink /etc/nginx/sites-enabled/default && \
sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf && \
echo "$VERSION_ARG" > /run/version && \
Expand Down
6 changes: 3 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[1]
<meta http-equiv="Cache-Control" content="no-cache" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="icon" href="/img/favicon.svg" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="icon" href="img/favicon.svg" type="image/x-icon">
[2]
</head>

Expand All @@ -28,7 +28,7 @@ <h1 id="info">[3]</h1>
[5]
</footer>
</div>
<script type="text/javascript" src="/js/script.js"></script>
<script type="text/javascript" src="js/script.js"></script>
</body>

</html>
9 changes: 7 additions & 2 deletions web/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var webSocketFactory = {

function getInfo() {

var url = "/msg.html";
var url = "msg.html";

try {
if (window.XMLHttpRequest) {
Expand Down Expand Up @@ -69,7 +69,12 @@ function processInfo() {

if (notFound) {
setInfo("Connecting to VNC", true);
var webSocket = webSocketFactory.connect("ws://" + window.location.host + "/websockify");

var protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
var path = window.location.pathname.replace(/[^/]*$/, '').replace(/\/$/, '');
var wsUrl = protocol + "//" + window.location.host + path + "/websockify";
var webSocket = webSocketFactory.connect(wsUrl);

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion web/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ server {
index vnc.html;

if ($request_uri = "/") {
return 301 /?resize=scale&reconnect=true&autoconnect=true;
return 301 ?resize=scale&reconnect=true&autoconnect=true;
}

}
Expand Down