Excerpts from Luca Toscano's message of agosto 31, 2017 1:55 :
Hi David, 2017-08-29 17:41 GMT+02:00 David Mugnai <dvd@xxxxxx>:Hi, I'm trying to configure a virtual host that, based on the host name, forwards the request on a backend server listening on an unix socket. My apache version is 2.4.18 as shipped by Ubuntu 16.04 The configuration I've tried so far is: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html LogLevel trace2 UseCanonicalName Off RewriteEngine On RewriteCond %{HTTP_HOST} ^(.+)\.example.com RewriteRule "(.*)" "unix:/home/user/%1/server.sock|http://127.0.0.1$1 [P,NE] ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> The rewrite module works as expected (in the log file I can see the full path to the unix socket), but trying to access the web server results in a "400 Bad Request" *without* the involvment of the backend server. I made a test with ProxyPass directive, and it works, but obviously is not what I want: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html LogLevel trace2 UseCanonicalName Off ProxyPass / unix:/home/user/subdomain1/server.sock| http://127.0.0.1/ ProxyPassReverse / unix:/home/user/subdomain1/server.sock| http://127.0.0.1/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> How can I fix it?Didn't have much time to try this use case manually but I have a couple of suggestions: 1) Do you find any log in the error_log that could give us some clue about the 400 returned? (maybe increasing the LogLevel to debug or trace)
up to trace8 :) unfortunately nothing relevant ends into the logs. I can see mod_rewrite doing its work but nothing about the 400
2) Have you tried https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypassmatch ?
Correct me if I am wrong, but ProxyPassMatch cannot match against the hostname, isn't it? David --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx