简体   繁体   English

使用Nginx的grails.serverURL无法正常工作

[英]grails.serverURL with Nginx doesn't work properly

I have my Grails 2.1 Application running within a Tomcat 7.x container. 我的Grails 2.1应用程序在Tomcat 7.x容器中运行。 It's called ROOT.war. 叫做ROOT.war。 Nginx takes care for routing. Nginx负责路由。 Both components are on their own Ubuntu 12.4 servers. 这两个组件都在自己的Ubuntu 12.4服务器上。

The grails.serverURL in Config.groovy is set to the prod Domain www.myproddomain.com. Config.groovy中的grails.serverURL设置为产品域www.myproddomain.com。 So far, everything works perfect. 到目前为止,一切正常。

If I now want to test the Grails App before I activate the tomcat in Nginx, so I tried to use the internal URL from the server such as internalipofserver:8080. 如果现在我想在Nginx中激活tomcat之前测试Grails应用程序,那么我尝试使用服务器的内部URL,例如internalipofserver:8080。 This works, but since the grails.serverURL is set to www.myproddomain.com, I cannot click around without beeing redirected to www.myproddomain.com which makes no sense to test then. 这行得通,但是由于grails.serverURL设置为www.myproddomain.com,如果没有重定向到www.myproddomain.com,我将无法四处浏览,因此无法进行测试。

If I now leave grails.serverURL away, the preview on internalipofserver:8080 works fine, but as soon as I activate this tomcat in nginx to be reachable under www.myproddomain.com, certain resources will be pulled from internaliofserver:8080. 如果现在我离开grails.serverURL,则internalipofserver:8080上的预览效果很好,但是一旦我在nginx中激活了该tomcat以使其可在www.myproddomain.com下访问,则某些资源将从internaliofserver:8080中提取。

It seems to me as of tomcat would kind of store the first address that the site was called and then use that url. 在我看来,从tomcat开始,该类型将存储该站点被调用的第一个地址,然后使用该URL。

Can you advise? 你能建议吗? Thank you. 谢谢。 Best Sullivan 最佳沙利文

grails.serverURL does not have anything to do with the outside url (except for absolute links generated from grails). grails.serverURL与外部url没有任何关系(从grails生成的绝对链接除外)。 You can configure your nginx to handle any domain and internally do the proper redirects. 您可以将nginx配置为处理任何域,并在内部进行适当的重定向。

The caching you have described is probably due to the browser cache. 您描述的缓存可能是由于浏览器缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM