简体   繁体   中英

Grails: how to remove AppName from production url

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!

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

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.

Is this an application that you inherited? If so I would suggested consulting with the original creator to see how he configured it for your architecture.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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