Proxy internal site with Apaches’ Proxy module

April 10, 2010 · Posted in Gentoo 

Being an Apache noob, I had to figure out how to create a Virtual Host on my Apache Webserver, which will point to my internal Icecast server.

One might wonder why I didn’t simply forward my Icecasts’ port on my router and deal with it. This is because I don’t like seeing <domain_name>:<port> format on my address page, plus I don’t feel confortable forwarding more and more ports on my router.

Digging into apaches documents, I came into two possible solutions. 1) mod_rewrite and 2)mod_proxy.  The first one looked quite complicated and I didn’t have neither the time nor the motivation to work on it. The second one looked quite simple so I gave it a try

The very first step was to rebuild apache with apache2_module_proxy enabled.

*echo “www-servers/apache apache2_module_proxy” >> /etc/portage/package.use/apache

*emerge apache

Remember to edit your /etc/conf.d/apache file and add  -D PROXY to APACHE2_OPTS variable

Moving on, I had to to create a new v.host like the following one:

<VirtualHost *:80>
 ServerName sound.<mydomain.org>
 ProxyRequests Off
 ProxyPass / http://192.168.15.44:44331/
 ProxyPassReverse / http://192.168.15.44:44331/
 <Location />
 Order allow,deny
 Allow from all
 </Location>
 ErrorLog /var/log/apache2/sound_error.log
</VirtualHost>

Lets explain what is going on here. First I create a new server name sound.<mydomain.org>. So when a user types this address, this vhosts is taking care of his requests.

ProxyRequests off: Prevent apache working as a forwarding proxy server. DONT FORGET THIS LINE as enabling ProxyRequests for your apache is a security leak.

ProxyPass: Map the root (/) of the specific vhost to the following internal url ( http://192…. )

ProxyPassReverse: Adjust the URL in the Location header on HTTP redirect responses. This is the exact reverse operation for the above directive.

Now, every time I type “sound.<mydomain.org>” on my addressbar, Icecasts’ starting page pops up. How great is that? :)

I really hope you find this tip useful like I did

Apache Proxy Module Documentation

Comments

7 Responses to “Proxy internal site with Apaches’ Proxy module”

  1. Tom on April 11th, 2010 11:38 pm

    For those that have multiple vhosts defined, would it be prudent to add “ProxyRequests Off” to each definition if proxy is enabled?

  2. Bud on April 12th, 2010 5:36 pm

    I usualy also add this line:
    ProxyPreserveHost on
    This means, that on the internal server the location header will be sound. and not 192.168.15.44

  3. Bud on April 12th, 2010 5:42 pm

    I usualy also add this line:
    ProxyPreserveHost on
    This means, that on the internal server the location header will be sound.mydomain.org. instead of 192.168.15.44.

    (Please delete my previous comment, the text inside angle brackets got deleted.)

  4. Josh on April 13th, 2010 6:15 am

    After following your guide I was receiving the following error in my Apache logs “proxy: No protocol handler was valid for the URL /”.

    After Googling a few posts I found that I had to also add the ‘proxy_http’ module to Apache’s APACHE2_MODULES variable and rebuild Apache again.

    Don’t forget to add the proxy modules to the /etc/apache2/httpd.conf file if they don’t already exists (as below):

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

    Running on Gentoo with Apache 2.2.15.

    Thanks for the post!

  5. Markos on April 13th, 2010 7:43 pm

    @Tom
    I guess not since they don’t make use of the proxy module

    @Bud
    Thanks very useful :)

    @I didn’t make such action. It was there when I rebuild Apache. All I had to do is to enable proxy module on /etc/conf.d/apache and add -D PROXY :). But thanks for the tip since others might encounter same behavior :)

  6. order levitra on April 19th, 2010 9:22 am

    http://www.lowcost-health-insurance.info/ low cost health insurance [url=http://www.lowcost-health-insurance.info/] low cost health insurance [/url] http://www.healthinsurance-companies.org/ health insurance companies [url=http://www.healthinsurance-companies.org/] health insurance companies [/url] http://www.healthinsurance-for-individuals.info/ health insurance for individuals [url=http://www.healthinsurance-for-individuals.info/] health insurance for individuals [/url] http://www.life-insurancequotes.info/ life insurance quotes [url=http://www.life-insurancequotes.info/] life insurance quotes [/url] http://www.life-insurancequote.biz/ life insurance quote [url=http://www.life-insurancequote.biz/] life insurance quote [/url] http://www.lifeinsurance-companies.org/ life insurance companies [url=http://www.lifeinsurance-companies.org/] life insurance companies [/url] http://www.staufferarabians.com/levitra.html order levitra online [url=http://www.staufferarabians.com/levitra.html] order levitra online [/url] http://www.1kmillionaires.com/ life insurance quotes [url=http://www.1kmillionaires.com/] life insurance quotes [/url] http://www.agelessphotography.com/ agelessphotography [url=http://www.agelessphotography.com/] agelessphotography [/url] http://www.dorsetmassage.com/levitra.html levitra online [url=http://www.dorsetmassage.com/levitra.html] levitra online [/url] 47621@gmail.com

  7. Rickie Manske on February 7th, 2011 1:41 am

    Hi, thank you so much for your fun post. I became looking to add your Feed but unfortunately it never are generally doing work for me. Are available others having this problem? I’ll return per day approximately to update. Regardless thanks a whole lot again for that piece.

Leave a Reply




GreekBloggers.com
Patras Wireless Metropolitan Network
Planet Hellug
iloog
forum hellug