From 994de92451a26ac31119219beda8782d746290f5 Mon Sep 17 00:00:00 2001 From: Karmaa Date: Wed, 12 Mar 2025 20:07:39 -0500 Subject: [PATCH] Changes to connection system to support docker --- docker/nginx.conf | 5 ++--- src/Terminal.jsx | 8 ++++---- src/backend/ssh.cjs | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/docker/nginx.conf b/docker/nginx.conf index 734a045f..9ba02608 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -24,16 +24,16 @@ http { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; # Fix this line to properly upgrade WebSockets + proxy_set_header Connection "Upgrade"; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; - # Pass real IPs for logging and security proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + # Proxy MongoDB socket requests location /database.io/ { proxy_pass http://127.0.0.1:8082; proxy_http_version 1.1; @@ -42,7 +42,6 @@ http { proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; - # Allow WebSockets to function properly proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; diff --git a/src/Terminal.jsx b/src/Terminal.jsx index 2c3a1ae8..fa985aa3 100644 --- a/src/Terminal.jsx +++ b/src/Terminal.jsx @@ -63,10 +63,10 @@ export const NewTerminal = forwardRef(({ hostConfig, isVisible }, ref) => { const socket = io( window.location.hostname === "localhost" - ? "http://localhost:8081/ssh.io" - : "/ssh.io", + ? "http://localhost:8081" // Modified path here + : "/", { - path: "/ssh.io/socket.io", + path: "/ssh.io/socket.io", // Same path, no need to modify transports: ["websocket", "polling"], } ); @@ -177,4 +177,4 @@ NewTerminal.propTypes = { port: PropTypes.string.isRequired, }).isRequired, isVisible: PropTypes.bool.isRequired, -}; +}; \ No newline at end of file diff --git a/src/backend/ssh.cjs b/src/backend/ssh.cjs index cf2b9e29..643136d3 100644 --- a/src/backend/ssh.cjs +++ b/src/backend/ssh.cjs @@ -4,9 +4,9 @@ const SSHClient = require("ssh2").Client; const server = http.createServer(); const io = socketIo(server, { - path: "/ssh.io/socket.io", + path: "/ssh.io/socket.io", // Corrected path for socket.io cors: { - origin: "*", + origin: "*", // Temporarily set to '*' to allow all origins. Change to specific URLs if needed. methods: ["GET", "POST"], credentials: true },