New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http server port in configuration file? #1449

Closed
fmeriaux opened this Issue Oct 3, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@fmeriaux

fmeriaux commented Oct 3, 2017

Hello,

I was wondering if it was possible in akka-http server, a way to set the default port directly in the configuration.

For example akka.http.server.default-http-port and why not akka.http.server.default-https-port.

Currently in an application using akka-http, if we want to configure the port of our server in a configuration file, we must implement it ourselves. I think it would be practical to have a way to do it directly.

@jrudolph

This comment has been minimized.

Show comment
Hide comment
@jrudolph

jrudolph Oct 4, 2017

Member

Thanks for the ticket, @fmeriaux.

I agree that could be useful. It is already now possible to omit the port with any of the Http.bindXXX methods. In that case an internal DefaultPortForProtocol is used as a marker and later replaced with statically determined values here:

private def choosePort(port: Int, connectionContext: ConnectionContext) = if (port >= 0) port else connectionContext.defaultPort

We could change that choosePort method to also take the settings into regard and add the settings you suggest in ServerSettings. We should then deprecate ConnectionContext.getDefaultPort as that cannot be changed to take settings into account.

Member

jrudolph commented Oct 4, 2017

Thanks for the ticket, @fmeriaux.

I agree that could be useful. It is already now possible to omit the port with any of the Http.bindXXX methods. In that case an internal DefaultPortForProtocol is used as a marker and later replaced with statically determined values here:

private def choosePort(port: Int, connectionContext: ConnectionContext) = if (port >= 0) port else connectionContext.defaultPort

We could change that choosePort method to also take the settings into regard and add the settings you suggest in ServerSettings. We should then deprecate ConnectionContext.getDefaultPort as that cannot be changed to take settings into account.

@dmitraver

This comment has been minimized.

Show comment
Hide comment
@dmitraver

dmitraver Oct 6, 2017

Contributor

I can pick this one if nobody works on it yet.

Contributor

dmitraver commented Oct 6, 2017

I can pick this one if nobody works on it yet.

@ktoso

This comment has been minimized.

Show comment
Hide comment
@ktoso

ktoso Oct 6, 2017

Member

Sure, that’d be great :)

Member

ktoso commented Oct 6, 2017

Sure, that’d be great :)

@dmitraver

This comment has been minimized.

Show comment
Hide comment
@dmitraver

dmitraver Oct 9, 2017

Contributor

I've implemented the change. Need to add some tests and will make a PR.

Contributor

dmitraver commented Oct 9, 2017

I've implemented the change. Need to add some tests and will make a PR.

@jlprat jlprat closed this in #1467 Oct 12, 2017

jlprat added a commit that referenced this issue Oct 12, 2017

#1449 Default http and https port configurations. (#1467)
* Adds configuration properties for http and https default ports.

* Adds missing methods for getting default http and https ports in server settings.

* Adds test for setting default http port via server settings.

* Adds mima filter for the new fields in ServerSettings.

* Small review fixes.

@jlprat jlprat added this to the 10.0.11 milestone Oct 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment