When setting up Apache as a reverse proxy for a Webrick server (or any backend service), the "No protocol handler was valid" error typically indicates missing protocol support modules. In Apache 2.2 (which Ubuntu 10.04 used), you need to explicitly load both mod_proxy
and mod_proxy_http
.
Your current configuration only loads the base proxy module:
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
But fails to load the HTTP protocol handler:
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
Here's the corrected version of your virtual host file:
<VirtualHost *:80>
ServerName test.local
ServerAdmin webmaster@localhost
# Must load both modules
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
ProxyPreserveHost On
ProxyRequests Off
# Static files exemption
ProxyPass /static !
DocumentRoot /var/www
# Proxy configuration
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
# Directory permissions
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/proxy-error.log
CustomLog /var/log/apache2/proxy-access.log combined
</VirtualHost>
Instead of loading modules within the VirtualHost (which can cause issues), better practice is to enable them globally:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo service apache2 restart
If issues persist, increase logging level temporarily:
LogLevel debug proxy:trace5
Check these common troubleshooting points:
- Verify backend service is running:
netstat -tulpn | grep 8080
- Test direct connection:
curl http://127.0.0.1:8080
- Check SELinux/apparmor restrictions
When using reverse proxy:
# Always disable forward proxy
ProxyRequests Off
# Restrict proxy access
<Proxy *>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Proxy>
When setting up a reverse proxy with Apache's mod_proxy to forward requests from test.local to a WEBrick server running on localhost:8080, you might encounter the frustrating 500 error with the message:
[Thu Mar 03 01:43:10 2011] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
This error typically occurs when Apache's mod_proxy is enabled but the required submodules (like mod_proxy_http) aren't loaded. The configuration you provided is mostly correct, but missing some crucial pieces.
Here's the corrected virtual host configuration that should work:
ServerName test.local
ServerAdmin webmaster@localhost
# Required proxy modules
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyPreserveHost On
ProxyRequests Off
# Static content exclusion
ProxyPass /static !
# Main proxy configuration
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
# Directory settings
DocumentRoot /var/www
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
# Proxy permissions
Require all granted
ErrorLog /var/log/apache2/test.local-error.log
CustomLog /var/log/apache2/test.local-access.log combined
LogLevel warn
- Make sure both
mod_proxy
andmod_proxy_http
are enabled - Use
Require all granted
instead of the deprecatedOrder allow,deny
syntax - Consider separating log files for each virtual host
- The
LoadModule
directives might need adjustment based on your Apache installation path
After making these changes:
- Check module status:
sudo apachectl -M | grep proxy
- Test configuration:
sudo apachectl configtest
- Restart Apache:
sudo systemctl restart apache2
If you still encounter issues:
# Check enabled modules
a2enmod proxy
a2enmod proxy_http
# Verify module files exist
ls /usr/lib/apache2/modules/mod_proxy*
Remember that on Ubuntu, you might need to use a2enmod
instead of LoadModule
directives in your virtual host configuration.