[Dancer-users] serving static and dynamic content separately

Mr. Puneet Kishor punk.kish at gmail.com
Sat Sep 17 22:29:33 CEST 2011


Pursuant to my earlier post in which I expressed curiosity about serving static and dynamic content from different servers, I have the following (not directly Dancer related but causing me to sub-optimally serve Dancer content) problem.

I am unable to configure apache2 frontend proxy to Starman and also serve apache2 content. My intent is to have apache2 serve some static content and some dynamic apps, both with domain names and those as sub-folders of the document root, and also serve some dynamic apps, both with domain names and without, proxied behind apache2. In other words, I want to do the following

http://my.server.edu/ (served by apache2 from "/Users/me/Sites")
http://my.server.edu/lib (served by apache2 from "/Users/me/Sites/lib")
http://my.server.edu/app0 (served by apache2 from "/Users/me/Sites/app0"
http://my.server.edu/app1 (served by Starman from "Users/me/Docs/www/app1")
http://vapp1.org (served by Starman from "Users/me/Docs/www/vapp1")
http://vapp1.org/lib (served by apache2 from "/Users/me/Sites")
http://subapp.vapp1.org (served by Starman from "Users/me/Docs/www/subapp")
http://subapp.vapp1.org/lib (served by apache2 from "/Users/me/Sites")

Here is my (simplified) conf file with my intent and the unexpected exhibited behavior in the comments.

	####################################################
	# Default settings for http://my.server.edu/
	####################################################
	Listen 80
	ServerName my.server.edu:80
	DocumentRoot "/Users/me/Sites"
    
	<Directory />
		Options FollowSymLinks
		AllowOverride None
		Order deny,allow
		Deny from all
	</Directory>
	
	<Directory "/Users/me/Sites">
		Options FollowSymLinks
		AllowOverride None
		Order allow,deny
		Allow from all
	</Directory>
	
	####################################################
	# Static content for http://my.server.edu/lib
	####################################################
	Alias /lib "/Users/me/Sites/lib"
	
	# The server responds with a "502 Bad gateway" error
	ScriptAlias /cgi-bin/ "/Users/me/cgi-bin/"
	
	<Directory "/Users/me/cgi-bin">
		AllowOverride None
		Options None
		Order allow,deny
		Allow from all
	</Directory>

	####################################################
	# Proxies
	####################################################
	ProxyRequests Off
	<Proxy *>
		Order deny,allow
		Allow from all
	</Proxy>
	
	# The following app should get their static content 
	# from http://my.server.edu/lib, but the server responds
	# with a "502 Bad gateway" error
	####################################################
	# http://my.server.edu/app1
	####################################################
	ProxyPass        /app1 http://127.0.0.1:5000
	ProxyPassReverse /app1 http://127.0.0.1:5000
	
	# The server responds with a "502 Bad gateway" error
	# when serving static content
	####################################################
	# Virtual host http://vapp1.org
	####################################################
	<VirtualHost *:80>
		ServerName vapp1.org
		
		####################################################
		# Static content for http://vapp1.org/lib
		####################################################
		Alias /lib "/Users/me/Sites/lib"
		
		ProxyRequests Off
		<Proxy *>
			Order deny,allow
			Allow from all
		</Proxy>
		ProxyPass        / http://127.0.0.1:5001
		ProxyPassReverse / http://127.0.0.1:5001
	</VirtualHost>
	
	#####################################################
	# Virtual host subdomain http://subapp.vapp1.org 
	#####################################################
	<VirtualHost *:80>
		ServerName subapp.vapp1.org 

		# The server responds with a "502 Bad gateway" error
		# when serving static content
		####################################################
		# Static content for http://subapp.vapp1.org/lib
		####################################################
		Alias /lib "/Users/me/Sites/lib"
		
		ProxyRequests Off
		<Proxy *>
			Order deny,allow
			Allow from all
		</Proxy>
		ProxyPass        / http://127.0.0.1:5002
		ProxyPassReverse / http://127.0.0.1:5002
	</VirtualHost>
	
As you can see from above, if I have the virtual host segments in my conf file, the server responds with a "502 Bad gateway" error for everything that is supposed to come from http://my.server.edu.

However, if I remove the virtual host segments, all other apps work just fine.

I am sure I had this working on a previous machine, but now I am unable to reproduce that. What am I doing wrong?


More information about the Dancer-users mailing list