7

URL of the HTTPS Grails application

 2 years ago
source link: https://www.codesd.com/item/url-of-the-https-grails-application.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

URL of the HTTPS Grails application

advertisements

My Grails app runs over HTTPS and in Config.groovy I've set:

environments {
    development {
        grails.serverURL = "https://localhost:8443/foo"
    }
}

When I execute grails run-app to start the app in dev mode, the last message printed on the console is:

Server running. Browse to http://localhost:8082/foo

If I accidentally click on this URL to access the application, I get various errors due to the same-origin security policy (because https://localhost:8443 is a different host to http://localhost:8082).

Why is Grails prompting me to access my app via http://localhost:8082/foo when I've set grails.serverURL = "https://localhost:8443/foo"

Update

I changed the startup command to grails run-app -https and the last message printed on the console is now:

Server running. Browse to http://localhost:8082/foo or https://localhost:8443/foo

Why am I given the option of either HTTP or HTTPS, rather than just the latter? Also, I get this exception during startup:

http11.Http11Protocol Failed to initialize end point associated with ProtocolHandler ["http-bio-8443"]
java.net.BindException: Address already in use <null>:8443
    at org.apache.tomcat.util.net.JIoEndpoint.bind(JIoEndpoint.java:407)

I've checked if port 8443 is in use before I run this command (it isn't), but the server seems to startup despite this exception, so this is not a major concern.


Replace grails.serverURL with the code below.

Its possible to set the port with the following system properties:

grails.server.port = 8082

That should work for both http and https. To configure for just one:

grails.server.port.https = 8082


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK