Reverse Proxy in Ubuntu

by 1:08 PM 27 comments
The last few days I have spend some time setting up 2 new servers. One running Railo on Ubuntu and the other Coldfusion in Windows. I needed to host this on a single IP address and needed both machines available on the internet. There are 2 ways I know of that can accomplish this task 1. Using Microsoft ISA and 2 Using Apache as a reverse proxy. As I already have Apache up and running I went with option 2. While a seemingly trivial task I had never done this before and got hung up a few times the following are the steps I took:

Define the urls you want to re-direct to a different server:

  ServerName www.myExternalDoomianName.com
  ProxyPass / http://myInternalDnsName/    ( or ip address )
  ProxyPassReverse / http:// myInternalDnsName /  (or ip address )
  ProxyPreserveHost on

ProxyPreserveHost keeps the host headers intact so the internal sever can still use virtual websites.
Enable the site ( debian/ubuntu specific )
A2ensite myReverseProxySites

Need some extra bits for apache:
apt-get install libapache2-mod-proxy-html
a2enmod proxy
a2enmod proxy_html
a2enmod headers
a2enmod proxy_connect
a2enmod proxy_balancer

Restart apache
/etc/init.d/apache2 restart

If something isn’t working start looking in the logs:
tail -f  /var/log/apache2/error.log

27 comments:

  1. Can you set this up on Windows running Apache?

    ReplyDelete
  2. @Damian

    Absolutely. It's just as easy on Windows.

    ReplyDelete
  3. Hi, I am planning to do a similar task. Reverse proxy with apache on ubuntu server to win 3k3 server. What version of ubuntu did you use. Will I be better off deploying current ubuntu server 9.04 or use 8.04?

    And did the windows sites work ok?

    ReplyDelete
  4. I used 8.04 at the time. 3 out of the 5 servers behind this proxy were Windows so the OS of the server behind the proxy doesn't matter.

    Since then I have moved this proxy to Apache on a Windows server it has been running faultlessly.

    ReplyDelete
  5. I thank you for the information and articles you provided

    ReplyDelete
  6. cool, please guidance so that I can create a blog like yours

    ReplyDelete
  7. D33DDC2E1BJasperC12AD49DBANovember 26, 2024 at 6:04 PM

    7E8D2531A7
    cam show

    ReplyDelete