Apache2 VirtualHost (ProxyPass and Alias) configuration works in Ubuntu but not on OSX

joewyrembelski picture joewyrembelski · Dec 17, 2012 · Viewed 12.4k times · Source

I have been using an Ubuntu machine for my development environment for years and am attempting to migrate to OSX (Mountain Lion). The only hiccup at this point is the apache2 configuration.

On the Ubuntu machine "apache2 -v" reveals

Server version: Apache/2.2.22 (Ubuntu)
Server built:   Nov  8 2012 21:37:30

On the OSX machine "httpd -v" reveals

Server version: Apache/2.2.22 (Unix)
Server built:   Aug 24 2012 17:16:58

So you can imagine that I'm thoroughly confused as to why the virtual host config isn't migrating well.

The following ProxyPass and Alias bits of my VirtualHost config work very well when used on my first apache2 instance but not on the second. The directory structures on both machines

For all intents and purposes, the virtual host config is as follows

NameVirtualHost *:80

<VirtualHost *:80>

   ProxyPass /img !
   Alias /img /somedir/media/img

   ProxyPreserveHost On
   ProxyPass / http://127.0.0.1:8080/
   ProxyPassReverse / http://127.0.0.1:8080/

</VirtualHost>

with the goal being that apache will serve all images and the app server at port 8080 doing the heavy lifting (common pattern).

In Ubuntu this works great. On the macbook, the images aren't being served up.

Answer

Jerry picture Jerry · Dec 18, 2012

Verify that the proxy module is being loaded. This would either be done with a dynamic load config line in the conf file:

LoadModule  proxy_http_module    modules/mod_proxy_http.so

Or compiled into Apache:

./httpd -l | grep proxy
mod_proxy.c
mod_proxy_connect.c
mod_proxy_ftp.c
mod_proxy_http.c
mod_proxy_scgi.c
mod_proxy_ajp.c
mod_proxy_balancer.c

You can likely pull the mod_proxy_http.so from the other server.