When migrating from IIS to Apache while maintaining backward compatibility, the standard approach of proxying subdomains (like iis.example.com) won't work when application licensing (like dotnetCharting) is tied to the primary domain. We need to proxy specific paths (www.example.com/charts/) while serving other content from Apache.
Here's a complete VirtualHost configuration that proxies /subdir/ to your IIS server while serving other content from Apache:
<VirtualHost *:80>
ServerName www.example.com
# Main document root for Apache content
DocumentRoot /var/www/html
# Proxy configuration for the subdirectory
<Location /subdir/>
ProxyPass http://iis-internal-ip/
ProxyPassReverse http://iis-internal-ip/
ProxyPreserveHost On
# Additional headers if needed for your dotnetCharting
RequestHeader set Host "www.example.com"
RequestHeader set X-Forwarded-Proto "http"
</Location>
# Other Apache configuration...
</VirtualHost>
If your IIS application generates absolute URLs, you'll need mod_rewrite to fix them:
RewriteEngine On
RewriteRule ^/subdir/(.*) http://iis-internal-ip/$1 [P]
ProxyPassReverse /subdir/ http://iis-internal-ip/
For HTTPS configurations, add these SSL-specific directives:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/key.pem
<Location /subdir/>
ProxyPass https://iis-internal-ip/
ProxyPassReverse https://iis-internal-ip/
RequestHeader set X-Forwarded-Proto "https"
</Location>
</VirtualHost>
After configuration, test with these commands:
# Check Apache syntax
apachectl configtest
# Test the proxy response
curl -v http://localhost/subdir/
curl -v https://localhost/subdir/ -k
If you encounter 502 errors or misrouted requests:
- Verify network connectivity between Apache and IIS
- Check IIS bindings accept requests from Apache
- Inspect Apache error logs (/var/log/apache2/error.log)
- Ensure mod_proxy and mod_proxy_http are enabled
For dotnetCharting specifically, you may need to add:
RequestHeader set Referer "http://www.example.com/subdir/"
When migrating from IIS to Apache while maintaining legacy system accessibility, developers often face a unique challenge when proprietary software licensing is tied to domain names. In our case, dotnetCharting's domain-based licensing requires creative reverse proxy configuration.
Apache's mod_proxy
and mod_proxy_http
modules can handle subdirectory proxying through careful VirtualHost configuration. Here's the technical implementation:
ServerName www.example.com
# Main document root for Apache content
DocumentRoot /var/www/html
# Proxy configuration for the subdirectory
ProxyPass /subdir http://iis-server.example.com/
ProxyPassReverse /subdir http://iis-server.example.com/
# Additional directives to handle URL rewriting
ProxyPassReverse /
ProxyPreserveHost On
RequestHeader set X-Forwarded-Proto "http"
The critical aspect is maintaining the original domain context for dotnetCharting. The ProxyPreserveHost On
directive ensures IIS receives the original Host header, making the licensing validation work seamlessly.
For more complex scenarios, consider these additional configurations:
# For SSL termination at Apache level
SSLEngine on
SSLCertificateFile /path/to/cert.pem
SSLCertificateKeyFile /path/to/key.pem
ProxyPass /subdir http://iis-server.example.com/
ProxyPassReverse /subdir http://iis-server.example.com/
# Handle WebSocket connections if needed
ProxyPass /subdir/ws ws://iis-server.example.com/ws
ProxyPassReverse /subdir/ws ws://iis-server.example.com/ws
If you encounter 502 errors or broken assets:
- Verify
mod_proxy
andmod_proxy_http
are enabled - Check SELinux/permissions if running on Linux
- Inspect Apache error logs for detailed proxy errors
- Test connectivity between Apache and IIS servers
For production environments, add these directives to your proxy configuration:
ProxyRequests Off
ProxyTimeout 300
ProxyVia On
ProxyBadHeader Ignore