Apache: proxy to unix socket named in URL Apache: proxy to unix socket named in URL unix unix

Apache: proxy to unix socket named in URL


Based on various docs on the net, the idea is to encompass both mod_proxy and mod_rewrite in two steps, namely, URL shall be processed to extract socket name and to be rewritten without that part, and proxy shall be done based on the new (shortened) URL and the socket name.

Here is how it could look like:

RewriteEngine OnRewriteRule      /(.*)/(.*)  http://%{HTTP_HOST}/$2    [P]ProxyPass        /           unix:/var/sockets/$1.sock|http://%{HTTP_HOST}/ProxyPassReverse /           unix:/var/sockets/$1.sock|http://%{HTTP_HOST}/

I ground my proposal on (.*) expressions which shall extract the two parameters of interest. Then we rewrite the URL and, by means of P flag we denote that it the result is to be passed to proxy. Later we specify two identical ProxyPass and ProxyPassReverse and specify Unix socket path, pipe | separator and host base address.

I hope this could work or at least give you some sketch of what shall we look for.