howto configure mod_proxy for apache2, jetty

5,082

If I understand correctly you need to replace this line

ProxyPass /blog http://foo.com/blog

with this line

ProxyPass /blog/ !

This instructs the apache2 server to not to proxy anything that starts with /blog which is I think is what your want.

UPDATE: The official docs is here: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

Share:
5,082

Related videos on Youtube

theTuxRacer
Author by

theTuxRacer

I am an inquisitive developer. Regular joe by day, TV freak by night. I love all things Android. Weaned off Ubuntu onto a Mac.. Back to linuxland with Fedora 28. I enjoy getting lost on my motorcycle. Also learning photography. Dabbling in both on a weekend is my idea of a day well spent. Student of Life, Laidback, Abrasive, Possesive, Obsessive.

Updated on September 17, 2022

Comments

  • theTuxRacer
    theTuxRacer almost 2 years

    This is how I have setup my environment, atm. An apache2 instance on port 80. Jetty instance on the same server, on port 8090.

    Use-Case:

    • When I visit foo.com, I should see the webapp, which is hosted on jetty, port 8090.

    • If I put foo.com/blog, I should see the wordpress blog, which is hosted on apache. (I read howtos on the web, and installed it using AMP.)

    Below are my various configuration files:

    /etc/apache2/mods-enabled/proxy.conf:

    ProxyPass / http://foo.com:8090/   << this is the jetty server
    
    ProxyPass /blog http://foo.com/blog
    
    ProxyRequests On
    ProxyVia On
    
    <Proxy *>
     Order deny,allow
     Allow from all
    </Proxy>
    
    ProxyPreserveHost On
    
    ProxyStatus On
    

    /etc/apache2/httpd.conf:

    LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
    LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
    LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
    LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
    

    I have not created any other files, in sites-available or sites-enabled.

    Current situation:

    • If I goto foo.com, I see the webapp.
    • If I goto foo.com/blog, I see a

    HTTP ERROR 404

    Problem accessing /errors/404.html. Reason:

    NOT_FOUND powered by jetty://

    • If I comment out the first ProxyPass line, then on foo.com, I only see the homepage, without CSS applied, ie, only text..
    • .. and going to foo.com/blog gives me a this error:

    The proxy server received an invalid response from an upstream server.

    The proxy server could not handle the request GET /blog.

    Reason: Error reading from remote server

    • I also cannot access /phpmyadmin, giving the same 404 NOT_FOUND error as above.

    I am running Debian squeeze on an Amazon EC2 Instance.

    Question: Where am I going wrong? What changes should I make in the proxy.conf (or another conf files) to be able to visit the blog?

  • theTuxRacer
    theTuxRacer over 13 years
    1. That doesnt work. It still forwards it to jetty. 2. Do u have any list or website, where I can see various types of proxypass
  • theTuxRacer
    theTuxRacer over 13 years
    EDIT: I changed the order of the ProxyPass, and put the / at the end. Now it works. I guess it would just pass through. Thanks for the answer, I had lost all hope, people like you keep the love alive! Happy new year :)
  • user649102
    user649102 over 13 years
    Thanks, you are welcome. Fixed I updated my answer accordingly.