Skip to content

Using webserver customizer to set port and configuring actuator on port 8080 doesn't work without setting server.port as well #22142

@pcornelissen

Description

@pcornelissen

In our project we need to tweak the SSL stack, so we use a WebServerFactoryCustomizer, which also sets the port to 8443.
When I tried to bind actuator to port 8080 using properties it didn't work and actuator was always on the public port.

As it turns out in ManagementPortType you check for:

return ((managementPort == null || (serverPort == null && managementPort.equals(8080))
  	   || (managementPort != 0 && managementPort.equals(serverPort))) ? SAME : DIFFERENT);

So when you modify the public server port using customizers, this doesn't work. @wilkinsona already stated in gitter that it may be difficult to to determine that in the OnManagementPortCondition, but I wanted to document this issue here and also provide the workaround:

Just set the server.port anyway, even if you override it in the customizer, if you want to have actuator on port 8080. (You could even use any value != 8080 if you override it anyway)

This also leads me to another small problem. I have also configured the management.server.address to "localhost" for security reasons an this also was ignored in this case, which opens the management interface to the public by accident, although it should have been "private".

May I suggest to add a property to override the ManagementPortType to make it explicit? This also opens the possibility to document that fact in the reference documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions