Virtual Host in Play Framework

Topics: Web server, IP address, Apache HTTP Server Pages: 4 (725 words) Published: September 2, 2012
n play fr
Set-up a front-end HTTP server
You can easily deploy your application as a stand-alone server by setting the application HTTP port to 80: %production.http.port=80
But if you plan to host several applications in the same server or load balance several instances of your application for scalability or fault tolerance, you can use a front-end HTTP server. Note that using a front-end HTTP server will never give you better performance than using Play server directly! Set-up with lighttpd

This example shows you how to configure lighttpd as a front-end web server. Note that you can do the same with Apache, but if you only need virtual hosting or load balancing, lighttpd is a very good choice and much easier to configure! The /etc/lighttpd/lighttpd.conf file should define things like this: server.modules = (

$HTTP["host"] =~ "" {
proxy.balance = "round-robin" proxy.server = ( "/" =>
( ( "host" => "", "port" => 9000 ) ) )

$HTTP["host"] =~ "" {
proxy.balance = "round-robin" proxy.server = ( "/" => (
( "host" => "", "port" => 9000 ),
( "host" => "", "port" => 9001 ) )
Set-up with Apache
The example below shows a simple set-up with Apache httpd server running in front of a standard Play configuration. LoadModule proxy_module modules/

ProxyPreserveHost On
ProxyPass /
ProxyPassReverse /

Apache as a front proxy to allow transparent upgrade of your application The basic idea is to run 2 Play instances of your web application and let the front-end proxy load-balance them. In case one is not available, it will forward all the requests to the available one. Let’s start the same Play application two times: one on port 9999 and one on port 9998. Copy the application...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Play as a Framework Essay
  • Essay on Play as a Framework for Learning
  • The Host Essay
  • Host Essay
  • Essay about The Host
  • Virtual Essay
  • Legal Framework Essay
  • framework Essay

Become a StudyMode Member

Sign Up - It's Free