Create Reverse Proxy for Apache to Allow SWAN Connections to Various Servers with Local LAN-based DynDNS Name

Abstract: Configure Apache as a reverse proxy to route external DynDNS requests to multiple internal LAN servers without exposing ports.

Created: 2026-10-07 by

Configuring Apache as a reverse proxy allows you to route external requests from a DynDNS hostname to internal servers on your LAN, effectively bridging the gap between dynamic public DNS and local network services. This setup enables secure access to web applications via SWAN or other tunneling methods without exposing ports directly to the internet.

Understanding the Reverse Proxy Architecture

A reverse proxy acts as an intermediary server that receives HTTP or HTTPS requests from clients and forwards them to one or more backend servers. In this specific configuration, the goal is to map a single DynDNS domain name to multiple internal services based on the requested path or subdomain. For instance, accessing server1.dyndns.org might route to 192.168.1.10:8080, while app.dyndns.org routes to 192.168.1.20:3000. This architecture provides several benefits. First, it centralizes SSL/TLS termination at the edge, meaning your internal servers do not need valid certificates for public domains. Second, it hides the internal network topology from external observers, enhancing security. Third, it allows you to change internal IP addresses or ports without updating your DynDNS records, as long as the Apache configuration is updated. If you are looking for alternative reverse proxy solutions like Traefik, which handles dynamic configurations automatically, you might want to review Setting Up Traefik for Reverse Proxy and Container Network on Tech Support Site.

Prerequisites and Module Installation

Before configuring the proxy, ensure your Apache installation has the necessary modules enabled. The core modules required are mod_proxy, mod_proxy_http, and optionally mod_ssl if you plan to terminate HTTPS connections. On Debian-based systems, these can be enabled using the following commands:
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer
a2enmod lbmethod_byrequests
systemctl restart apache2
On Red Hat-based systems, you may need to install the httpd-tools package and ensure the modules are loaded in the main configuration file. Verify that the modules are active by checking the output of apachectl -M for proxy_module and proxy_http_module. Without these modules, Apache will reject proxy-related directives with a 500 Internal Server Error.

Configuring Virtual Hosts for DynDNS Routing

The heart of the solution lies in the Apache Virtual Host configuration. You should create a separate virtual host file for each service or group of services you wish to expose. Below is a template for a basic HTTP reverse proxy configuration. Note that for production environments, you should always use HTTPS.
<VirtualHost *:80>
    ServerName myservice.dyndns.org
    
    # Enable Proxy
    ProxyPreserveHost On
    
    # Redirect all traffic to the backend server
    ProxyPass / http://192.168.1.10:8080/
    ProxyPassReverse / http://192.168.1.10:8080/
    
    # Optional: Logging
    ErrorLog ${APACHE_LOG_DIR}/myservice-error.log
    CustomLog ${APACHE_LOG_DIR}/myservice-access.log combined
</VirtualHost>
Key directives include ProxyPreserveHost On, which ensures the original Host header sent by the client is passed to the backend server. This is crucial for applications that rely on the domain name for routing or authentication. The ProxyPass directive maps the URL path on the proxy to the backend address, while ProxyPassReverse adjusts the Location headers in responses from the backend to match the proxy's URL structure. If you encounter issues where the virtual host does not respond as expected, check for syntax errors using apachectl configtest. Common pitfalls include incorrect permissions on log directories or conflicts with default virtual hosts. For macOS users specifically dealing with Apache vHost issues, see Cannot Get vHost Working on Apache for MacBook (macOS Sonoma 14.4.1, Apache 2.4.58).

Implementing HTTPS Termination

To secure your DynDNS connection, you must configure SSL. This involves obtaining a certificate for your DynDNS domain. Since many DynDNS providers do not support direct SSL certificate issuance for free dynamic IPs, you may need to use Let's Encrypt with a manual validation process or a dedicated DDNS plugin. Once you have the certificate files (fullchain.pem and privkey.pem), update your Virtual Host configuration:
<VirtualHost *:443>
    ServerName myservice.dyndns.org
    
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/myservice.crt
    SSLCertificateKeyFile /etc/ssl/private/myservice.key
    
    ProxyPreserveHost On
    ProxyPass / http://192.168.1.10:8080/
    ProxyPassReverse / http://192.168.1.10:8080/
</VirtualHost>
Ensure that port 443 is open in your firewall and that your router forwards traffic from the external interface to the Apache server's internal IP. If you are managing TLS versions, remember to disable insecure protocols like TLSv1.0 and TLSv1.1 to comply with modern security standards. For guidance on securing these protocols, refer to TLSv1.0 and TLSv1.1 Still Active.

Testing and Troubleshooting

After applying the configuration, restart Apache and test the connectivity from an external network. Use tools like curl or a browser to access your DynDNS name. Check the Apache error logs if you receive a 502 Bad Gateway error, which typically indicates that the backend server is unreachable or refusing connections. Ensure that your internal firewall allows traffic from the Apache server to the backend service on the specified port. For more complex setups involving multiple devices on a local network, consider reviewing Setting up Reverse Proxy across Multiple Devices on Local Network to understand how to balance loads or route traffic efficiently. Additionally, if you are running PHP applications behind the proxy, monitor Troubleshooting PHP-FPM Apache Logging to diagnose backend processing issues.

Frequently Asked Questions

Can I use a free DynDNS provider with Apache reverse proxy?

Yes, you can use any DynDNS provider that supports A record updates. However, some free providers may have limitations on SSL certificate issuance. It is recommended to use a provider that allows easy integration with Let's Encrypt or supports wildcard certificates for easier management.

How do I handle WebSocket connections through the reverse proxy?

You need to enable mod_proxy_wstunnel and add specific rewrite rules to upgrade the connection. Add ProxyPass /ws ws://backend-ip:port/ws and ProxyPassReverse /ws ws://backend-ip:port/ws to your Virtual Host configuration to support WebSocket traffic.

What happens if the backend server goes down?

By default, Apache will return a 502 Bad Gateway error to the client. To improve resilience, you can configure load balancing with multiple backend servers using mod_proxy_balancer, which will automatically failover to a healthy server if one becomes unavailable.

Is it safe to expose internal services via DynDNS?

It is safer than opening ports directly because the reverse proxy can enforce authentication, rate limiting, and IP whitelisting. However, you should always use HTTPS and keep your Apache version updated to protect against known vulnerabilities. Consider adding a Web Application Firewall (WAF) for additional protection.

Why am I getting a "Connection Refused" error?

This usually means the backend service is not running or is listening on a different port. Verify the backend service status using netstat or ss and ensure that the Apache server can reach the backend IP address. Check for local firewall rules that might be blocking outbound connections from the Apache server.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More