0

I am trying to deploy Grails 2.2.3 project to a production and having issue with URL. I setup reverse proxy in Apache and have http://example.com -- as example.

I set following property in Config.groovy:

grails.serverURL = "http://example.com/"

and set in the application.properties following:

app.context=/

However all of my resources and links always reference to

http://example.com/AppName/...

How do I remove application name ("AppName") from resource and links reference?

Example of resources:

<r:require modules="bootstrap"/>
<g:javascript library="jquery"/>

Example of environments Config.groovy:

environments {
    development {
        grails.logging.jul.usebridge = true
    }
    production {
        grails.logging.jul.usebridge = false

        grails.serverURL = "http://example.com/"
        grails.app.context = "/"
    }
}

I think Grails application must have some sort of property that could be set!? Otherwise it seems like a pain the neck.

Please help!

P.S: If I access any resource directly (manually remove AppName from URL) I get the right stuff such as css, js and image.

Update: I set following in application.properties:

app.context=/
serverURL=http://example.com/

and created absolute URL in grails:

<g:createLink controller="Sample" absolute="true"/>

and it creates proper URL!!! However resources use relative path and start with AppName/... It seems like a curse, I just can't get rid of that AppName.

Update: If I run prod run-app then all URLs come out properly, however the moment I deploy to Tomcat 7, AppName appears in URLs again.

MeIr
  • 7,236
  • 6
  • 47
  • 80

1 Answers1

0

There are other options, but probably the shortest approach is to deploy it like ROOT.war.

Just change the default war filename in the BuildConfig.groovy:

 grails.project.war.file = "target/ROOT.war"

Set the right grails.serverURL property for you and you're done.

Hope it helps.

Ivan Arrizabalaga
  • 686
  • 1
  • 7
  • 22
  • 1
    Sorry, but I can't user ROOT.war, is there any other way? – MeIr May 19 '14 at 10:14
  • First check that there is no other app deployed as the ROOT ("/") app in the tomcat, otherwise they will collide. Then try with grails.app.context = '/', but NOT in application.properties (Config.groovy or a properties file using locators). – Ivan Arrizabalaga May 19 '14 at 11:17