Howto configure mod_proxy for apache2, jetty

apache-2.2jettymod-proxy

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?

Best Answer

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

Related Topic