1

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.

3 Answers 3

3

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 
Sign up to request clarification or add additional context in comments.

2 Comments

Actually, I'm trying to get it running on port 8443 on HTTPS. I tried removing grails.serverURL and adding just grails.server.port.https = 8443, but it still prompts me to access it via http://localhost:8082/foo
But what is running on https? From the docs listed above: Arguments: https - Start an HTTPS server (on port 8443 by default) alongside the main server. Just to be clear, the application will be accessible via HTTPS and HTTP.
1

You need to use the --https parameter to run-app for Grails to respond to HTTPS and HTTP in development mode. At least according to the documentation.

Try using

grails run-app --https 

Further more, the grails.serverURL is typically used by taglibs and plugins, and not the launching process as far as I can tell.

Comments

1

You can set the ssl port you want to run you application on via https in BuildConfig.groovy. You can add the following to your BuildConfig.groovy

//You can specify another port here to get rid of your startup exception grails.server.port.https="8443"
grails.server.host="localhost"

Then try grails run-app -https and you should be able to run your app on the ssl port you defined or the default 8080 port

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.