Setting management.endpoints.web.base-path to root when server.servlet.context-path is set - spring-boot

I'm trying to set the base path of the actuator to / so that PCF can access it.
I am Using SpringBoot 2.1.4
The applications all have configured context roots. Setting management.endpoints.web.base-path only changes the path relative to the application context root.
Is there a way to set the management path to root when there is an application context root? Or is there some way to hack SB2 so all requests to a path get routed to all my RequestMappings?

If by "so that PCF can access it", you mean Pivotal Apps Manager, and you are using a context path with your app then you need to apply this workaround.
That will allow you to use a context path with your app, but still expose the actuator endpoints so that Pivotal Apps Manager can consume them.
Hope that helps!

Related

How to prefix all controller paths but not management endpoints?

I have a Spring Boot application with a lot of controllers, and I want to run the service on a sub-path of an existing domain. So I've figured it would be nicer to have this configurable than to hardcode the path into all the request mappings.
I've considered all the approaches mentioned here https://www.baeldung.com/spring-boot-controllers-add-prefix, but they either also change the prefix of the actuator endpoints or are not globally enforced, so I'd prefer a different approach.
I want the actuator endpoints on /_system/ (changed by management.endpoints.web.base-path=/_system) and have only the /prefix as a load balancer target, so the management endpoints won't ever be reachable from the internet (in case I miss-configure the application and start leaking some sensitive info from the management endpoints).
I've also tried configuring management.server.base-path=/, but that seems to also be affected by the server.servlet.context-path and spring.mvc.servlet.path as the actuator seems to be registered "under" the main servlet dispatcher.
I was looking into registering a separate servlet dispatcher just for the actuator endpoints, but I've given up on researching it after some time because I feel like I'd have to override half of Spring Boot.
Any other ideas? Thanks

(How) Can I run more than one Spring Boot application on the same server and port?

I have a Spring Boot web application that I'd like to split up into about six separate applications; one would provide the homepage and login at endpoints under "/", and the others would each claim a subdirectory path ("/subsystem1", "/subsystem2", etc...). I have a pretty clear idea how I could use JWT to pass authentication/authorization from the login app to the others.
The main reason for this is so that each subsystem can be modified or updated without shutting down the others. And organizationally, so we don't have to subject the entire app to a QA process when only one subsystem is changed.
Is it possible to set up multiple Spring Boot instances to run on the same server at the same time and the same port, with different paths/directories to their endpoints? How?
I was unable to find any duplicate question, but here are two related questions that may offer clues:
From Is there a standard way to customize the deploy path in Spring Boot? I learned that I can set the application property server.servlet.context-path to prefix the whole application with a subdirectory name (e.g. "/subsystem1"). But I still can't run two apps at the same time, even if both claim different subdirectories. Spring Boot reports "Web server failed to start. Port 8080 was already in use."
There's Multiple Spring-boot applications running on one Tomcat
but I'd prefer to use standalone Spring applications with their embedded Tomcat instances rather than the less-recommended WAR packaging and deployment to an external Tomcat container.
This one looks promising -- Deploying Multiple Spring Boot Web Applications in Single Server -- but the answers focus on whether standalone or Tomcat container deployments are better, and doesn't touch on the "how-to" question.
Acceptable answers:
If, as ekalin suggests, it is impossible to have multiple Spring Boot apps listen to the same port, here are a couple of ideas I have brainstormed (but don't know how to accomplish):
Perhaps the instances could be running on different ports but the main app (the one with the login page) could "forward" or redirect to the other apps in some way that hides their true URLs? E.g. "localhost:8080/subsystem1" would be an alias for "localhost:8081/".
Perhaps the applications could each have their own Docker containers, all running within a shared Docker network, and we use Docker somehow to map each URL path to the right app? Could this be set up with docker-compose?
We set up a proxy server of some kind that remaps URL paths to the separate applications.
You can't have more than one application listening on a port. How would the kernel which application to send the packages to?
You could run an http server such as nginx listening on 8080, and each application in a different port, and then proxy the requests based on the URL to the desired application.

Listing all deployed rest endpoints (spring-boot, tomcat)

I know there is a similar kind of question exist but if works only for glassfish server.
Listing all deployed rest endpoints (spring-boot, jersey)
Is it possible to list all my configured rest-endpoints with spring boot? The actuator lists all existing paths on startup, I want something similar for my custom services, so I can check on startup if all paths are configured correctly and use this info for client calls.
How do I do this? I use #Path/#GET annotations on my service beans and register them via ResourceConfig#registerClasses.
Is there a way to query the Config for all Paths?
Update2: I want to have something like
GET /rest/mycontroller/info
POST /res/mycontroller/update
...
In my opinion, you are already using the right tool (actuator) to answer to your request.
Actuator gives you all the rest method running and you can configure it on your own, by disabling/enabling specific endpoints
If you have a look on the documentationprobably it can help you.
In any case, the default configuration of actuator display the endpoints (built-in in Intellij for your development).

Google app engine flexible not load context path of Spring boot application

I have spring boot application and already deploy on GAE Flexible env.
In my application, I already set my application context path in application.properties file look like:
server.context-path=/myapp
And it work fine on tomcat and jetty embedded server.
But when I deploy to GAE flex env my application not work with context path that I already set on my application.properties file.
It auto use context path "/" in GAE domain.
Because I'm using dispatch to defined routing on GAE with multi microservice, so I have to define a specify context path for each service.
Anybody can help me in this case?
Thanks.

Modify ldap provider url without restarting the spring security application

we are providing facility to customer to configure ldap server runtime. But when i modify provider server url used in constructor of context source, the application crashes. Is there any way to change ldap server url at runtime? for LdapAuthenticationProvider.
If this is a case where you are changing the provider because one may be down for some reason, you should set up multiple authentication providers (security:authentication-provider) in your spring-security config file. Spring-security will start at the top of the list & keep trying until it finds one that works. That way you can leave this setup & not have a need to redeploy your code.

Resources