3

I use an Apache server as a proxy for my playframework application. The proxy configure file is like this:

> <VirtualHost *:80>
>     ProxyPreserveHost Off
>     ServerAdmin redhorse@viform.net
>     DocumentRoot "/home/admin/www"
>     ServerName viform.net
>     ErrorLog "logs/viform.net-error.log"
>     ProxyPass /zh-cn/ http://localhost:9000/
>     ProxyPassReverse /zh-cn/ http://localhost:9000/  
> </VirtualHost>

When I access http://viform.net/zh-cn/signin, It shows me the correct page. But the urls of static resources in the page are not correct. The generated html page code is like this:

     ...
    <script type="text/javascript" src="/public/javascripts/base.js">
    </script>
    <script type="text/javascript" src="/public/javascripts/secure/submitbutton.js">
    </script>
    <script type="text/javascript" src="/public/javascripts/secure/signinpanel.js">
    </script>
    ...

The browser can not find these resources since their src paths should start with "/zh-cn". Is there anyone can help me figure this out? Thanks.

redhorse
  • 31
  • 2

2 Answers2

4

There are a few posts on this topic in the Play Group, and there is another question on SO how to use "war.context" in Configuration file of Play Framework ? that is similar.

If you look at this post on GoogleGroups, you will see that the expected configuration is to specify the context in your routes file. For example..

%{ ctx = play.configuration.getProperty('ctx', '') }%

GET     ${ctx}/            Application.index
GET     ${ctx}/hello     Application.hello

Where you would put the following in your app conf file.

ctx=zh-cn
Community
  • 1
  • 1
Codemwnci
  • 54,176
  • 10
  • 96
  • 129
  • If ProxyPreserveHost is set with Off in the Apache config file, the proxy will work correctly without modifying the routes file for this case. But the generated html code will be incorrect like what i came across. You solution can solve my problem. I change the code in the view files like this: `` Thanks for your quick response. – redhorse May 05 '11 at 08:01
1

As of play-1.2.2 there is a new configuration property in conf/application.conf called

http.path

In your example, try setting it like this:

http.path=/ch-cn

it should work.

Jörgen Lundberg
  • 1,799
  • 3
  • 22
  • 31