Apache Reverse Proxy leads to error 500, AH01144: No protocol handler was valid for the URL

Written by - 0 comments

Published on - Listed in Apache Varnish Linux


After an Apache2 web server's configuration was adjusted to include a Varnish cache, the website threw a HTTP 500 Internal Server error instead of showing the website.

HTTP 500 /  AH01144: No protocol handler was valid

The following drawing represents the new data flow:

Note: The previous configuration went from the Front Reverse Proxy directly to Varnish. The problem with this? There are no access logs to be analyzed for statistics (as Varnish does not generate access logs). Only the traffic skipping Varnish or uncached content would create an access log when requests were reaching the application on the Apache2 Backend.

The Apache2 reverse proxy configuration seemed correct and was compared to other working examples:

<VirtualHost *:80>
  ServerName www.example.com
  DocumentRoot /var/www/example
  CustomLog /var/log/apache2/www.example.com.access.log combined
  ErrorLog /var/log/apache2/www.example.com.error.log

  # Serving as Reverse Proxy to Varnish
  ProxyPreserveHost On
  ProxyPass / http://127.0.0.1:6081/
  ProxyPassReverse / http://127.0.0.1:6081/
  RequestHeader set X-Forwarded-Proto "https"

</VirtualHost>

But as soon as a request arrived on the "Apache2 Reverse Proxy" listening on port tcp/80, an error 500 was shown:

ck@front:~# curl -H "Host: www.example.com" http://example -H "X-Forwarded-Proto: https" -I
HTTP/1.1 500 Internal Server Error
Date: Wed, 14 Aug 2024 05:39:30 GMT
Server: Apache/2.4.61 (Debian)
Connection: close
Content-Type: text/html; charset=iso-8859-1

The Apache error log showed the following entry:

[Wed Aug 14 07:35:06.738954 2024] [proxy:warn] [pid 3958895:tid 3958895] [client 192.168.12.2:44906] AH01144: No protocol handler was valid for the URL / (scheme 'http'). If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

mod_proxy is not enough

The first thing coming into mind was: Did I actually enable the proxy module? 

root@example:~# a2enmod proxy
Module proxy already enabled

And yes, it's already enabled. So what is causing the error?

As it turns out, the proxy module is not enough for this kind of reverse proxying - the proxy_http module is also needed:

root@example:~# a2enmod proxy_http
Considering dependency proxy for proxy_http:
Module proxy already enabled
Enabling module proxy_http.
To activate the new configuration, you need to run:
  systemctl restart apache2

root@example:~# systemctl restart apache2

Once mod proxy_http was enabled, traffic is now correctly handled and reverse proxied to Varnish:

ck@front:~# curl -H "Host: www.example.com" http://example -H "X-Forwarded-Proto: https" -I
HTTP/1.1 200 OK
Date: Wed, 14 Aug 2024 05:34:09 GMT
Server: Apache/2.4.61 (Debian)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Link: <https://www.example.com/wp-json/>; rel="https://api.w.org/", <https://www.example.com/wp-json/wp/v2/pages/1388>; rel="alternate"; title="JSON"; type="application/json", <https://www.example.com/>; rel=shortlink
X-TEC-API-VERSION: v1
X-TEC-API-ROOT: https://www.example.com/wp-json/tribe/events/v1/
X-TEC-API-ORIGIN: https://www.example.com
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
X-Varnish: 393267 15
Age: 501
Via: 1.1 varnish (Varnish/6.5)
X-Cacheable: YES
Accept-Ranges: bytes
Content-Length: 73538


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder