Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Reverse Proxy Unix Socket

I am trying to setup ProxyPass in Apache 2.4.7 using unix sockets to a puma server for a rails application. I keep receiving a 500 Internal Error. When I check the apache logs I receive this message:

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 is my proxy config in apache

ProxyPass / unix:///home/rails/rp/tmp/sockets/puma.sock|http://127.0.0.1/
ProxyPassReverse / unix:///home/rails/rp/tmp/sockets/puma.sock|http://127.0.0.1/

If I setup a Proxy Pass on a regular tcp port like this, it works fine.

ProxyPass / http://127.0.0.1:9292
ProxyPassReverse / http://127.0.0.1:9292

Any help is appreciated, let me know if you need anymore information.

like image 879
drewlsvern Avatar asked Apr 10 '16 08:04

drewlsvern


2 Answers

In general, there is some point for checking for reverse proxy an http server app over unix socket:

  • Check if Apache already loaded required modules (proxy & http_proxy) using apachectl -M command
  • Make sure that socket path is accessible for www-data user (it is default apache user)
  • Check correctness of running app on unix socket using following command:
    curl --unix-socket /var/www/app/socket/path -XGET http:/someMethod
  • Check that ProxyPreserveHost On already present in your virtual host file and set socket address correctly (as unix:/var/www/path/to/your/socket) and after pipe mark path correctly (as |http://127.0.0.1/what/ever)
  • Make sure both ProxyPassReverse and ProxyPass is set correctly
like image 134
S.M.Mousavi Avatar answered Sep 27 '22 23:09

S.M.Mousavi


I am not sure which proxy handler should handle sockets, so you could try loading them all then see which one does the job for you:

https://httpd.apache.org/docs/trunk/mod/mod_proxy.html

Note that you can also use SetHandler to specify the module you want to handle your connections

like image 41
Nick M Avatar answered Sep 27 '22 22:09

Nick M