stream {
upstream ssh {
server 172.18.31.2:22;
}
// set up SSL session with certificate for
marvel.com,
www.marvel.com upstream marvel {
server 127.0.0.1:4431;
}
server {
listen 127.0.0.1:4431 ssl;
ssl_certificate certs/marvel.pem;
ssl_certificate_key certs/marvel.key;
proxy_ssl on;
proxy_pass https_backend;
}
// set up SSL session with certificate for
dccomics.com,
www.dccomics.com upstream dccomics {
server 127.0.0.1:4432;
}
server {
listen 127.0.0.1:4432 ssl;
ssl_certificate certs/dccomics.pem;
ssl_certificate_key certs/dccomics.key;
proxy_ssl on;
proxy_pass https_backend;
}
// route connection to the tunnel with correct certificate
map $ssl_preread_server_name $upstream {
default ssh;
marvel.com marvel;
www.marvel.com marvel;
dccomics.com dccomics;
www.dccomics.com dccomics;
}
upstream ssh {
server 172.18.31.2:22;
}
server {
listen 443;
ssl_preread on;
proxy_pass $upstream;
}
}