Skip to content
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

Allow specifying the port (or nic) for Spring Boot Actuator #2408

Closed
trustin opened this issue Jan 17, 2020 · 2 comments · Fixed by #2502
Closed

Allow specifying the port (or nic) for Spring Boot Actuator #2408

trustin opened this issue Jan 17, 2020 · 2 comments · Fixed by #2502
Milestone

Comments

@trustin
Copy link
Member

trustin commented Jan 17, 2020

WebOperationService is currently always bound to Server's all ports. It'd be nice if there's a way to limit/disable WebOperationService for other ports than a specific port/remoteAddr/NIC.

Armeria currently is not capable of binding a service to a specific port only, but we could simply respond with 404 if the request came from a wrong port. Internally this could be implemented as a generic decorator that works for any HttpService.

As a workaround, a user can specify a custom route decorator:

@Bean
public ArmeriaServerConfigurator secureActuator() {
    return builder -> {
		builder.routeDecorator()
               .pathPrefix("/internal")
               .build((delegate, ctx, req) -> {
                   final InetSocketAddress laddr = ctx.localAddress();
                   if (laddr.getPort() != INTERNAL_PORT) {
                       return HttpResponse.of(404);
                   } else {
                       return delegate.serve(ctx, req);
                   }
               });
    };
}
@heowc
Copy link
Contributor

heowc commented Feb 14, 2020

In spring boot actuator, the base path of the provided actuator is /actuator.
In addition, is there a need to include internal/docs, internal/metrics and internal/healthcheck in armeria?

@trustin
Copy link
Member Author

trustin commented Feb 14, 2020

@heowc Yes. It'd be nice to provide this feature as a part of the core, too.

trustin pushed a commit that referenced this issue Jun 4, 2020
…2502)

Motivation:

`WebOperationService` is currently always bound to `Server`'s all ports. It'd be nice if there's a way to limit/disable `WebOperationService` for other ports than a specific port/remoteAddr/NIC.

Armeria currently is not capable of binding a service to a specific port only, but we could simply respond with 404 if the request came from a wrong port. Internally this could be implemented as a generic decorator that works for any `HttpService`.

Modifications:

- Copy `ArmeriaSetting` to `boot-actuator-autoconfigure`
- If `management.server.port` is set, protect all services under `/internal/` and actuator services on other ports.
- If `management.server.port` is set, support `@LocalManagementPort`
- Add test

Result:

- Fixes #2408
@trustin trustin added this to the 0.99.7 milestone Jun 22, 2020
fmguerreiro pushed a commit to fmguerreiro/armeria that referenced this issue Sep 19, 2020
…ine#2502)

Motivation:

`WebOperationService` is currently always bound to `Server`'s all ports. It'd be nice if there's a way to limit/disable `WebOperationService` for other ports than a specific port/remoteAddr/NIC.

Armeria currently is not capable of binding a service to a specific port only, but we could simply respond with 404 if the request came from a wrong port. Internally this could be implemented as a generic decorator that works for any `HttpService`.

Modifications:

- Copy `ArmeriaSetting` to `boot-actuator-autoconfigure`
- If `management.server.port` is set, protect all services under `/internal/` and actuator services on other ports.
- If `management.server.port` is set, support `@LocalManagementPort`
- Add test

Result:

- Fixes line#2408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants