Skip to main content

Networking Setup

Overview

This document details the network architecture used to securely expose the OpenStack infrastructure (INF1 and INF2) and the mail server using SSH reverse tunnels and NGINX reverse proxies. A VPS acts as a public gateway to forward traffic from the internet to internal services running on private networks.


SSH Reverse Tunnel: Mail Server Exposure (INF1 Controller)

The Mailcow mail server runs inside the INF1 controller node on a private network. To expose SMTP, SMTPS, IMAPS, and POP3S services externally, an SSH reverse tunnel is created from the INF1 controller node to the VPS (92.222.178.88):

ssh -fN -o ServerAliveInterval=60 \
-R 2525:localhost:25 \
-R 2587:localhost:587 \
-R 2465:localhost:465 \
-R 2993:localhost:993 \
-R 2995:localhost:995 \
[email protected]

Ports correspond to standard mail services:

  • SMTP: 25, 587 (submission)
  • SMTPS: 465
  • IMAPS: 993
  • POP3S: 995

The ServerAliveInterval=60 option helps keep the tunnel alive.
The -fN options run SSH in the background without opening a shell.

Port Forwarding on VPS for Mail Server

To map public-facing mail ports on the VPS to the tunneled ports, socat listeners are set up:

sudo socat TCP-LISTEN:587,fork,reuseaddr TCP:localhost:2587 &     # SMTP (submission)
sudo socat TCP-LISTEN:465,fork,reuseaddr TCP:localhost:2465 & # SMTPS
sudo socat TCP-LISTEN:993,fork,reuseaddr TCP:localhost:2993 & # IMAPS
sudo socat TCP-LISTEN:995,fork,reuseaddr TCP:localhost:2995 & # POP3S

These allow external clients to connect securely to the mail services hosted inside the private network.


SSH Reverse Tunnel: OpenStack Services Exposure

To expose OpenStack services running on INF1 and INF2 securely through the VPS, reverse SSH tunnels are established from the VPS back to the internal hosts:

ssh -fN \
-R 56080:172.20.20.241:6080 \ # Horizon
-R 58774:localhost:8774 \ # Nova API
-R 58778:localhost:8778 \ # Nova API
-R 59292:localhost:9292 \ # Glance
-R 5500:localhost:5000 \ # Keystone
-R 59696:localhost:9696 \ # Neutron
-R 58776:localhost:8776 \ # Nova API
-R 58443:localhost:443 \ # HTTPS Proxy
-R 58000:localhost:8000 \ # Magnum API
-R 58004:localhost:8004 \ # Heat API
[email protected]

Updated mapping for OpenStack services:

Tunnel PortServiceInternal Port
5500Keystone5000
58774Nova API8774
58776Nova API8776
58778Nova API8778
59292Glance API9292
56080Horizon (VNC)6080
59696Neutron API9696
58443HTTPS Proxy443
58000Magnum API8000
58004Heat API8004

NGINX Reverse Proxy Configuration on VPS

NGINX acts as the TLS termination point and reverse proxy for incoming requests, forwarding them to tunneled ports.

Mail Server Proxy (mail.ulmexa.com)

server {
listen 80;
server_name mail.ulmexa.com;

root /var/www/html;
index index.html;

location /.well-known/acme-challenge/ {
allow all;
}

location / {
return 404;
}
}

server {
listen 443 ssl;
server_name mail.ulmexa.com;

ssl_certificate /etc/letsencrypt/live/mail.ulmexa.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mail.ulmexa.com/privkey.pem;

location / {
proxy_pass http://<k8s-mailu-ip>:80; # Kubernetes Mailu service IP
proxy_set_header Host $host;
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;
}
}

OpenStack Proxy (openstack.ulmexa.com)

Example for Keystone service:

server {
listen 5000 ssl;
server_name openstack.ulmexa.com;

ssl_certificate /etc/letsencrypt/live/openstack.ulmexa.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/openstack.ulmexa.com/privkey.pem;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
proxy_pass https://localhost:5500/; # Tunnel endpoint
proxy_set_header Host $host;
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;
}
}

Other OpenStack APIs (Nova, Glance, Neutron, Horizon, Magnum, Heat) are exposed on their respective ports with similar proxy blocks.


Summary Table of Ports and Services

ServiceInternal Host/PortVPS Tunnel PortPublic Access URL
Mailcow SMTPINF1 Controller: 25, 5872525, 2587mail.ulmexa.com:587
Mailcow SMTPSINF1 Controller: 4652465mail.ulmexa.com:465
Mailcow IMAPSINF1 Controller: 9932993mail.ulmexa.com:993
Mailcow POP3SINF1 Controller: 9952995mail.ulmexa.com:995
KeystoneINF1/INF2: 50005500openstack.ulmexa.com:5000
Nova APIINF1/INF2: 8774, 8776, 877858774, 58776, 58778openstack.ulmexa.com:8774, 8776, 8778
Glance APIINF1/INF2: 929259292openstack.ulmexa.com:9292
Horizon (VNC)INF1/INF2: 608056080openstack.ulmexa.com:6080
Neutron APIINF1/INF2: 969659696openstack.ulmexa.com:9696
Magnum APIINF1/INF2: 800058000openstack.ulmexa.com:8000
Heat APIINF1/INF2: 800458004openstack.ulmexa.com:8004

Network Flow Visual

Network Flow