Hello everyone.
I am facing problem where cannot succeed with the proper reverse proxy configuration for the App having needing resources (js|css|ico|txt|jpg|svg) to load as well so it can work.
Scenario is that I have a Spring Boot App with Angular on the frontend. I have built a Docker image of this app.
How it looks locally:
opening in browser:
http://192.168.255.11:59901/spring/webapp
(no trailing slash)
will redirect to:
http://192.168.255.11:59901/spring/webapp/login?returnUrl=%2F
giving you the app (with all resources like js|css|owa|etc.. loaded):
How I want to to look like publicly:
a) alias_for_client.example.com (addPrefix: /spring/webapp
) - access only to angular context
b) alias_for_admin.example.com/webapp (addPrefix: /spring
) - access to admin tools of spring boot (/spring/swagger
, /spring/explorer
, /spring/h2-database
, /spring/acucator
, etc.
Simply put I want to have http://192.168.255.11:59901
put under subdomain and strip the path segment (or add it in the background) as described above.
Config example for scenario a) (access only to angular context at /spring/webapp
)
http:
routers:
alias1.example.com:
entryPoints:
- websecure
rule: Host(`alias1.example.com`)
service: alias1.example.com
services:
alias1.example.com:
loadBalancer:
passHostHeader: true
servers:
- url: 'http://192.168.255.11:59901'
middlewares:
- alias1.example.com+addPrefix
middlewares:
alias1.example.com+addPrefix:
addPrefix:
prefix: /spring/webapp
alias1.example.com+replacePathRegex:
replacePathRegex:
regex: "^/spring/webapp"
replacement: "/"
alias1.example.com+redirectRegex:
redirectRegex:
regex: "^https?://([^/]+)/?$"
replacement: "https://$1/spring/webapp"
permanent: true
-- don't mind those other 2 middlewares - I was experimenting.. active is only the first one.
If somebody can point me what I might be doing wrong please. Thanks!