I set up nginx as a reverse proxy for two proxied servers. Each of them (proxy and proxied servers) is running as a container in a docker environment. Proxied server appalpha
is simply an nginx:alpine
serving a static webpage (just for demo and testing purposes). All works fine here because things are simple.
The other proxied server's image is kanboard/kanboard
. When I try to access this service through my reverse proxy at https://example.com/kanboard/
I first get an expected http response with status code 302 (Found)
. But the header is set to Location: /login
(i.e pointing to my reverse proxy) which does not exist. My expectation is to see a header field of Location: /kanboard/login
here.
I tried with several proposed configurations without success:
- without
proxy_redirect
- with
proxy_redirect
- with
rewrite
(which is not the right concept here, as far as I understand)
- with
return
(which is not the right concept here neither, right?!)
What am I doing wrong?
My proxy.conf
of the nginx reverse proxy lists as follows:
server {
listen 443 ssl http2;
server_name example.com;
server_tokens off;
ssl_certificate /etc/nginx/ssl/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com.key;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1.3;
ssl_ciphers "HIGH !aNULL !eNULL !EXPORT !CAMELLIA !DES !MD5 !PSK !RC4";
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/nginx-2443.log;
proxy_cache_valid any 1s;
location /alpha {
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_pass http://appalpha/;
}
location /eval_kanboard {
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_pass https://restore_eval_kanboard/;
}
}
I appreciate your help.
Cheers Thomas