13

I just wanted to test a reverse proxy simple setup, redirecting every request just to google. Anyhow it does not work! Trying to browse on localhost, I just get the apache "it works" default page, but not proxying.

Of course I loaded the modules proxy, proxy_http. Following file is placed under sites-available, with symbolic link in sites-enabled. I also restarted the server. What could be wrong?

<VirtualHost 192.168.1.2:8080>
      ProxyRequests off
      ProxyPreserveHost On
      <proxy *>
      Order deny,allow
      Allow from all
      </proxy >
      ProxyPass / http://www.google.de
      ProxyPassReverse / http://www.google.de
</VirtualHost >

2 Answers 2

10

The default vhost (which serves content from /var/www, where the "It works" page lives) is getting the requests.

It's loading first, and you haven't specified a ServerName for your new vhost, so the "default" vhost will get every request. Run apache2ctl -S - it will show you how it's assigning requests.

If you don't want to use the default site, disable it with a2dissite default, then restart Apache - requests will then be sent to your new proxying <VirtualHost>.

Additionally, your trailing slashes should always match when proxying. Add them at the end:

ProxyPass / http://www.google.de/
ProxyPassReverse / http://www.google.de/
2
  • I'm testing out the above but when I run apachectl -S I don't see my port being forwarded. I only see port 443 and port 80. Any ideas? @Shane Madden
    – FabricioG
    Nov 14, 2018 at 23:22
  • Ugh never mind I was editing the wrong file @Shane Madden
    – FabricioG
    Nov 15, 2018 at 0:25
0

If anyone else is facing this, note that just reloading apache is not enough.

I had to restart apache.

sudo service apache2 restart
1
  • Did you enable a module in the process? A reload usually suffices for config changes, a restart is only needed for module changes. Oct 26, 2023 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .