开发者

Can not generate correct URLs for static resources with playframework when using Apache as a Proxy

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:

     ...
    <scr开发者_开发知识库ipt 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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜