To access your Docker container running at port 4533 through XAMPP's Apache server on port 80 using a proxy, you'll need to:
- Enable required Apache modules.
- Modify
httpd-vhosts.conf
to define the virtual host and proxy configuration.
- (Optional) Modify
httpd-ssl.conf
if you want to serve via HTTPS.
- Restart Apache via XAMPP.
- Use PHP to automate the editing of
httpd-vhosts.conf
.
✅ Final Goal:
Access Docker container (running at localhost:4533
) via:
http://localhost/navidrome
✅ Step-by-Step Instructions
✅ Step 1: Enable Apache proxy modules in XAMPP
Edit httpd.conf
(usually in C:\xampp\apache\conf\httpd.conf
) and make sure these lines are uncommented:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule rewrite_module modules/mod_rewrite.so
✅ Step 2: Update httpd-vhosts.conf
Edit C:\xampp\apache\conf\extra\httpd-vhosts.conf
and add this VirtualHost configuration:
<VirtualHost *:80>
ServerName localhost
# Proxy path for navidrome
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy *>
Require all granted
</Proxy>
# Proxy /navidrome path to the container's port
ProxyPass "/navidrome" "http://localhost:4533"
ProxyPassReverse "/navidrome" "http://localhost:4533"
# Optional: redirect root if needed
# RedirectMatch ^/$ /navidrome/
</VirtualHost>
✅ Step 3: Restart Apache from XAMPP Control Panel
After editing, restart Apache to apply changes.
✅ Step 4: Write PHP Code to Automate Step 2
This PHP code appends the required virtual host config to httpd-vhosts.conf
.
<?php
$vhostFile = 'C:/xampp/apache/conf/extra/httpd-vhosts.conf';
// Define the configuration block
$proxyConfig = <<<EOD
# Auto-generated VirtualHost for Navidrome Docker Proxy
<VirtualHost *:80>
ServerName localhost
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy *>
Require all granted
</Proxy>
ProxyPass "/navidrome" "http://localhost:4533"
ProxyPassReverse "/navidrome" "http://localhost:4533"
</VirtualHost>
EOD;
// Append to the vhosts file
if (file_put_contents($vhostFile, $proxyConfig, FILE_APPEND | LOCK_EX)) {
echo "Proxy configuration successfully added to httpd-vhosts.conf.\n";
echo "Please restart Apache from XAMPP to apply changes.";
} else {
echo "Failed to write proxy config. Please check file permissions.";
}
?>
✅ Step 5: Access via Browser
After restarting Apache, open:
http://localhost/navidrome
This should reverse-proxy to your Docker container running Navidrome at localhost:4533
.
🔒 (Optional) Step 6: Update httpd-ssl.conf
for HTTPS
If you want to enable https://localhost/navidrome
, let me know and I’ll give you a secured config using httpd-ssl.conf
.
Would you like a button in your PHP app that automatically writes the config and restarts Apache as well (if running on Windows)?