21

I have apache couchDB active on http://localhost:5984/ which i need to access at http://localhost:80/couch/. I need to setup a reverse proxi for this. Need help with the configuration settings.

PS: Whats the best resource to learn about apache?

Jaseem
  • 2,236
  • 6
  • 28
  • 35

1 Answers1

28

Setting up the proxy

To set up a reverse-proxy with Apache2, you first need to enable the Apache proxy module and virtualhosts. To enable the proxy module (mod_proxy), edit the Apache configuration file (Apache/conf/httpd.conf) and uncomment the following lines:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule unique_id_module modules/mod_unique_id.so

You then need to enable VirtualHosts. To do this, just uncomment the following line from the same configuration file:

Include conf/extra/httpd-vhosts.conf

Finally, you need to edit Apache/conf/extra/httpd-vhosts.conf and write in it the proxy directives. From the information you gave, they should look like this:

<VirtualHost *:80>
  ServerAdmin ******
  DocumentRoot "******"
  ServerName *****

  ProxyRequests Off
  ProxyVia Off

  ProxyPass /couch/ http://127.0.0.1:5984/
  ProxyPassReverse /couch/ http://127.0.0.1:5984/
</VirtualHost>

(+ some mLog directives and a few others).

-> Apache restart -> profit.

Learning Apache

You should have a look at the official documentation on the Apache official website or Apachetutor.org, though Google is, and always will be, everyone's friend.

Nicolas BRERO
  • 505
  • 5
  • 6
  • 1
    Hi, can you update theanswer according to apache2 ? – PeakGen Jul 24 '15 at 11:10
  • Hi, the answer is already intended for Apache2. Anything I can help you with? – Nicolas BRERO Aug 03 '15 at 10:08
  • 1
    I think he's referring to the fact that there is no "httpd.conf" file in a normal apache2 install on a modern linux install, say, Ubuntu 18.04 – Brian Leishman Sep 25 '19 at 16:47
  • whoever ends up here for this awesome answer saving one time and stress energy, might also be interested in how to activate those modules on ubuntu: `a2enmod proxy`, `a2enmod proxy_http`, `a2enmod unique_id`, `sudo apachectl -k restart` – Petrov. Ivan Petrov Mar 18 '22 at 13:26