Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: custom terminal host

Andras Bacsai8179a5c6a336
diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml
index 3eb270a2a0..9777c52dfc 100644
--- a/docker-compose.prod.yml
+++ b/docker-compose.prod.yml
@@ -46,6 +46,9 @@ services:
- PUSHER_APP_ID
- PUSHER_APP_KEY
- PUSHER_APP_SECRET
+ - TERMINAL_PROTOCOL
+ - TERMINAL_HOST
+ - TERMINAL_PORT
- AUTOUPDATE
- SELF_HOSTED
- SSH_MUX_ENABLED
diff --git a/resources/views/livewire/project/shared/terminal.blade.php b/resources/views/livewire/project/shared/terminal.blade.php
index 8aca10a0ff..d54bb7c639 100644
--- a/resources/views/livewire/project/shared/terminal.blade.php
+++ b/resources/views/livewire/project/shared/terminal.blade.php
@@ -50,18 +50,34 @@
function initializeWebSocket() {
if (!socket || socket.readyState === WebSocket.CLOSED) {
- // Only use port if Coolify is used with ip (so it has a port in the url)
- let postPath = ':6002/terminal/ws';
- const port = window.location.port;
- if (!port) {
- postPath = '/terminal/ws';
+ const predefined = {
+ protocol: "{{ env('TERMINAL_PROTOCOL') }}",
+ host: "{{ env('TERMINAL_HOST') }}",
+ port: "{{ env('TERMINAL_PORT') }}"
}
- let url = window.location.hostname;
- // make sure the port is not included
- url = url.split(':')[0];
- socket = new WebSocket((window.location.protocol === 'https:' ? 'wss://' : 'ws://') +
- url +
- postPath);
+ const connectionString = {
+ protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
+ host: window.location.hostname,
+ port: ":6002",
+ path: '/terminal/ws'
+ }
+ if (predefined.host) {
+ connectionString.host = predefined.host
+ }
+ if (predefined.port) {
+ connectionString.port = `:${predefined.port}`
+ }
+ if (predefined.protocol) {
+ connectionString.protocol = predefined.protocol
+ }
+ if (!window.location.port) {
+ connectionString.port = ''
+ }
+ console.log(connectionString)
+ const url =
+ `${connectionString.protocol}://${connectionString.host}${connectionString.port}${connectionString.path}`
+ console.log(url)
+ socket = new WebSocket(url);
socket.onmessage = handleSocketMessage;
socket.onerror = (e) => {