To avoid exposing port 1443 directly, use Apache as a reverse proxy.
1. Enable required Apache modules
Run the following commands to enable the necessary modules:
sudo a2enmod headers
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel
sudo a2enmod rewrite
2. Update Virtual Host configuration
Insert the following configuration into your Apache virtual host file. This configuration ensures that:
- The original domain name is preserved (
ProxyPreserveHost on). - Generated URLs use
https (X-Forwarded-Proto https). - Static files (like PNG or CSS) are served directly by Apache.
- WebSocket connections are routed to the Send WS connection.
- All other requests are routed to the Send HTTP connection.
# Enable rewrite engine
RewriteEngine on
# Make sure the original domain name is forwarded to Send
ProxyPreserveHost on
# Make sure the generated URL is https
RequestHeader set X-Forwarded-Proto https
# If it's a normal file (e.g. PNG, CSS) just return it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]
# If it's a websocket connection, redirect it to a Send WS connection
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:1443/$1 [P,L]
# Otherwise redirect it to a normal HTTP connection
RewriteRule ^/(.*)$ http://127.0.0.1:1443/$1 [P,QSA]
ProxyPassReverse "/" "http://127.0.0.1:1443"
3. Test and Restart
Always test your configuration before restarting Apache:
sudo apache2ctl configtest
sudo systemctl restart apache2