Update 2. I want to add and forward all traffic to localhost/admin/
instead of localhost/
.
- App listen to those paths:
localhost/
(then gets 302 tolocalhost/login
by application),localhost/overview
,localhost/books/details
, etc.
- I want admin user to use those urls:
localhost/admin/
(to get 302localhost/admin/login
by application)localhost/admin/overview
localhost/admin/books/details
- With my reverse proxy (see below):
localhost/admin/
(I get 302localhost/login
by application)
,
I could use also ingrees-nginx-controller
instead of mounting file.
In docker nginx.conf (or similar to k8s)
server {
listen 80 default_server;
listen [::]:80 default_server;
...
location /admin {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host/admin;
proxy_pass http://<conteiner2>.docker-network;
}
...
}
Update1
For kubernetes I am trying to setup the the ingress-nginx
For this I installed the ingress-nginx-controller
and I setup the ingress-nginx
using this YAML:
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
more_set_headers "Host $host";
more_set_headers "X-Real-IP $remote_addr";
more_set_headers "X-Forwarded-For $proxy_add_x_forwarded_for";
more_set_headers "X-Forwarded-Proto $scheme";
more_set_headers "X-Forwarded-Host $host/admin";
name: test-ingress
namespace: <namespace>
spec:
rules:
- http:
paths:
- path: /admin
backend:
serviceName: <app1>-admin
servicePort: 8002