-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TLS port with routing to either SSH or HTTP server according to the SNI servername, using the same socket
- Loading branch information
Roy Razon
authored
Feb 11, 2024
1 parent
845aaf2
commit 3eb8d73
Showing
6 changed files
with
85 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,23 @@ | ||
version: '3.7' | ||
## NEED TO ADD TLS CONFIGURATION for traefik and stunnel | ||
|
||
secrets: | ||
tls-key: | ||
file: ./tls/key.pem | ||
configs: | ||
tls-cert: | ||
file: ./tls/cert.pem | ||
sslh-config: | ||
file: ./tls/sslh.conf | ||
|
||
services: | ||
proxy: | ||
environment: | ||
BASE_URL: ${BASE_URL:-https://local.livecycle.run:8044} | ||
sslh: | ||
image: oorabona/sslh:v2.0-rc1 | ||
command: [sslh-ev, --config=/etc/sslh/config] | ||
configs: | ||
- source: sslh-config | ||
target: /etc/sslh/config | ||
|
||
stunnel: | ||
image: dweomer/stunnel | ||
environment: | ||
- STUNNEL_SERVICE=proxy | ||
- STUNNEL_ACCEPT=0.0.0.0:443 | ||
- STUNNEL_CONNECT=sslh:2443 | ||
- STUNNEL_KEY=/etc/certs/preview-proxy/key.pem | ||
- STUNNEL_CRT=/etc/certs/preview-proxy/cert.pem | ||
- STUNNEL_DEBUG=err | ||
ports: | ||
- '8044:443' | ||
BASE_URL: ${BASE_URL:-https://local.livecycle.run:8443} | ||
secrets: | ||
- source: tls-key | ||
target: /etc/certs/preview-proxy/key.pem | ||
target: /app/tls/key.pem | ||
configs: | ||
- source: tls-cert | ||
target: /etc/certs/preview-proxy/cert.pem | ||
target: /app/tls/cert.pem | ||
ports: | ||
- '8030:3000' | ||
- '8443:8443' | ||
- '2223:2222' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Logger } from 'pino' | ||
import http from 'http' | ||
import ssh from 'ssh2' | ||
import tls from 'tls' | ||
|
||
export const createTlsServer = ({ log, httpServer, sshServer, tlsConfig, sshHostnames }: { | ||
log: Logger | ||
httpServer: Pick<http.Server, 'emit'> | ||
sshServer: Pick<ssh.Server, 'injectSocket'> | ||
tlsConfig: tls.TlsOptions | ||
sshHostnames: Set<string> | ||
}) => tls.createServer(tlsConfig) | ||
.on('error', err => { log.error(err) }) | ||
.on('secureConnection', socket => { | ||
const { servername } = (socket as { servername?: string }) | ||
log.debug('TLS connection: %j', servername) | ||
if (servername && sshHostnames.has(servername)) { | ||
sshServer.injectSocket(socket) | ||
} else { | ||
httpServer.emit('connection', socket) | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.