I'm trying to use apache as a proxy server to redirect some requests to a service running on a different port. I'm attempting to follow the instructions here: http://httpd.apache.org/docs/2.4/rewrite/proxy.html
I've done exactly this to install (and nothing else):
sudo apt-get install apache2
sudo a2enmod rewrite
sudo a2enmod proxy
sudo a2enmod proxy_http
Then edited /etc/apache2/httpd.conf to be:
RewriteEngine on
RewriteRule ^/(.*) http://localhost:9200/$1 [P]
ProxyPassReverse / http://localhost:9200/
Then finally, restarted apache2 (sudo service apache2 restart
). Eventually, I'll add some real conditions to that rule, but I'm just trying to test it for now.
But it's not working. curl -XGET localhost:80/foo
fails with a 404 response, curl -XGET loaclhost:9200/foo
succeeds. Nothing useful in the error log or access log.
I would recommend setting your Apache reverse proxy commands to be something like this; note the
ProxyPass
setting as well asProxyRequests
andProxyPreserveHost
settings:I would also recommend you check the headers of the response output in
curl
by using the-I
option like this:It should show you the exact response from the server so you can fully understand what might be failing and what might be working.