Apache Proxy: No protocol handler was valid
Asked Answered
B

9

271

I am trying to proxy a subdirectory to another server. My httpd.conf:

RewriteEngine On
ProxyPreserveHost On
RewriteRule .*subdir/ https://anotherserver/subdir/ [P]

The problem is that Apache is always logging this:

AH01144: No protocol handler was valid for the URL /subdir/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: http://localhost/

So after searching the internet, I have activated these modules:

LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_express_module modules/mod_proxy_express.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_html_module modules/mod_proxy_html.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule rewrite_module modules/mod_rewrite.so

(I know that I don't need all of them but I just activated them to be sure I am not missing one)

But this error still appears and clients get a HTTP 500.

How can I fix this?

Borgerhout answered 29/5, 2014 at 11:11 Comment(5)
seems it's need some HTTPS handler for the proxy request. Try HTTP instead...Mediatize
I think you need mod_ssl and SSLProxyEngine with ProxyPassMediatize
@Mediatize Yes, this is working. If you post this as an answer, I can accept itBorgerhout
possible duplicate of Setup mod_proxy on apache http serverCottonade
see also apple.stackexchange.com/a/401045/57019Gales
C
607

This can happen if you don't have mod_proxy_http enabled

sudo a2enmod proxy_http

For me to get my https based load balancer working, i had to enable the following:

sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
Cavalcade answered 25/9, 2014 at 18:3 Comment(11)
I had to also had to do a 'sudo a2enmod proxy_wstunnel' , for my use case.Bolection
For me it was LoadModule ssl_module modules/mod_ssl.so. I also had to use SSLProxyEngine on.Cathee
For me, xampp didn't start with proxy_balancer, but it is not needed, so I've removed it.Bemire
I also had to enable mod_slotmem_shmStpierre
For me on WAMP, I installed the modules above via the menu and had to uncomment LoadModule slotmem_shm_module modules/mod_slotmem_shm.so in httpd.confMaidenly
I needed sudo a2enmod proxy_connect , which is to tunnel https using CONNECTSkinner
proxy_http was the only additional module i needed to resolve this issue, on a ubuntu 16.04 installBookbinder
Use loglevel warn proxy:trace6 or similar to get a more detailed message. AH01144 is just a failure message at the end. Something has been declined, but you will only know this with a higher trace level.Amendatory
in macos, i had to enable these components by commenting them out from /etc/apache2/httpd.conf file and then it worked.Snowden
How do i check whats wrong with my system? I am having this issue as well and I am using Ubuntu 18.04, apache2, php 7.2 with FPM.Hagiology
Not sure, been too long - I'd look in your /var/log/apache2/error.log file, and see if there's any signs. If none, I'd enable them one by one until it worked, then disable some until it didnt workCavalcade
L
27

For my Apache2.4 + php5-fpm installation to start working, I needed to activate the following Apache modules:

sudo a2enmod proxy
sudo a2enmod proxy_fcgi

No need for proxy_http, and this is what sends all .php files straight to php5-fpm:

<FilesMatch \.php$>
    SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost"
</FilesMatch>
Lorianne answered 3/11, 2015 at 15:9 Comment(1)
Yes, for fcgi this is true, but I had a HTTP proxy. :)Borgerhout
C
22

In my case, I needed proxy_ajp module.

a2enmod proxy proxy_http proxy_ajp 
Clingy answered 28/11, 2016 at 2:30 Comment(1)
Thank you! It was proxy_ajp that I needed!Gherlein
G
15

This was happening for me in my Apache/2.4.18 (Ubuntu) setup. In my case, the error I was seeing was:

... AH01144: No protocol handler was valid for the URL /~socket.io/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

The configuration related to this was:

  ProxyPass /~socket.io/ ws://127.0.0.1:8090/~socket.io/
  ProxyPassReverse /~socket.io/ ws://127.0.0.1:8090/~socket.io/

"No protocol handler was valid for the URL /~socket.io/" meant that Apache could not handle the request being sent to "ws://127.0.0.1:8090/~socket.io/"

I had proxy_http loaded, but also needed proxy_wstunnel. Once that was enabled all was good.

Gielgud answered 28/11, 2018 at 15:57 Comment(2)
indeed proxy_wstunnel was needed for me alsoHamsun
proxy_wstunnel is obviously required for websockets (in addition to proxy_http)Juback
C
10

To clarify for future reference, a2enmod, as is suggested in several answers above, is for Debian/Ubuntu. Red Hat does not use this to enable Apache modules - instead it uses LoadModule statements in httpd.conf.

More here: https://serverfault.com/questions/56394/how-do-i-enable-apache-modules-from-the-command-line-in-redhat

The resolution/correct answer is in the comments on the OP:

I think you need mod_ssl and SSLProxyEngine with ProxyPass – Deadooshka May 29 '14 at 11:35

@Deadooshka Yes, this is working. If you post this as an answer, I can accept it – das_j May 29 '14 at 12:04

Cholent answered 26/1, 2017 at 16:58 Comment(0)
E
4

I am posting an answer here, since I had the same error message for a different reason.

This error message can happen, for example, if you are using apache httpd to proxy requests from a source on protocol A to target on protocol B.

Here is the example of my situation:

AH01144: No protocol handler was valid for the URL /sockjs-node/info (scheme 'ws').

In the case above, what was happening was simply the following. I had enabled mod proxy to proxy websocket requests to nodejs based on path /sockjs-node.

The problem is that node does not use the path /sockjs-node for websocket requests exclusively. It also uses this path for hosting REST entrypoints that deliver information about websockets.

In this manner, when the application would try to open http://localhost:7001/sockjs-node/info, apache httpd would be trying to route the rest call from HTTP protocol to to a Webscoket endpoint call. Node did not accept this.

This lead to the exception above.

So be mindful that even if you enable the right modules, if you try to do the wrong forwarding, this will end with apache httpd informing you that the protocol you tried to use on the target server is not valid.

Expectation answered 10/12, 2017 at 21:16 Comment(1)
It was probably proxy_wstunnel. See first comment on accepted answer.Saltant
H
4

In my case, all modules were correctly set up (https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension is a good starter) & I had the redirection working for a base url, let's say /mysite/ but I got the errors for any child ULR, let's say /mysite/login/

http://reverse-proxy.dns.com/mysite/ was properly redirected to the remote servers while http://reverse-proxy.dns.com/mysite/login/ failed at the Apache2 reverse proxying with OP's error message.

The issue was the ending / character in the proxypass directive "/mysite/". Working configuration for child URL is :

<Proxy balancer://mysite_cluster>
    BalancerMember http://192.x.x.10:8080/mysite
    BalancerMember http://192.x.x.11:8080/mysite
</Proxy>
<VirtualHost *:80>
    [...]
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass "/mysite" "balancer://mysite_cluster"
    ProxyPassReverse "/mysite" "balancer://mysite_cluster"       
</VirtualHost>

Trailing / truly are tricky.

Hatband answered 7/10, 2020 at 9:52 Comment(0)
Z
1

I tried to get an uwsgi:// working, but somehow the manual thought it was clear to me that I actually needed mod_proxy_uwsgi. It was not. Here is how you do it: How to compile mod_proxy_uwsgi or mod_uwsgi?

Zina answered 13/6, 2018 at 11:4 Comment(0)
R
1

For me all above-mentioned answers was enabled on xampp still not working. Enabling below module made virtual host work again

LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
Razo answered 3/6, 2020 at 18:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.