gpt4 book ai didi

proxy - 使用 Apache 作为代理时,无法使用 playframework 为静态资源生成正确的 URL

转载 作者:行者123 更新时间:2023-12-01 11:57:10 25 4
gpt4 key购买 nike

我使用 Apache 服务器作为我的 playframework 应用程序的代理。代理配置文件是这样的:

> <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>

当我访问 http://viform.net/zh-cn/signin 时, 它显示了正确的页面。但是页面中静态资源的url不对。生成的html页面代码是这样的:

     ...
<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>
...

浏览器无法找到这些资源,因为它们的 src 路径应该以“/zh-cn”开头。有没有人可以帮我解决这个问题?谢谢。

最佳答案

Play Group里有几个关于这个主题的帖子,SO上还有一个问题how to use "war.context" in Configuration file of Play Framework ?那是相似的。

如果您在 GoogleGroups 上查看此帖子,您将看到预期的配置是在路由文件中指定上下文。例如..

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

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

您将在您的应用配置文件中放置以下内容。

ctx=zh-cn

关于proxy - 使用 Apache 作为代理时,无法使用 playframework 为静态资源生成正确的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5892581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com