Hello,
I'm trying to run cAdvisor docker image with nginx proxy. The problem is that I need to set up a proxy from different then root context - my goal is to have cAdvisor running behind e.g. http://localhost/cadvisor/ Here is my exemplary nginx config:
server {
listen 82;
server_name ${HOSTNAME};
set $cadvisor cadvisor.docker;
location ~ ^/cadvisor/(.*)$ {
rewrite ^/cadvisor/(.*) /$1 break;
proxy_pass http://$cadvisor:8080;
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_connect_timeout 150;
proxy_send_timeout 100;
proxy_read_timeout 100;
proxy_buffers 16 64k;
proxy_busy_buffers_size 64k;
client_max_body_size 256k;
client_body_buffer_size 128k;
}
}
The problem is that application assumes that the web context is set to "/", that's why I get redirected to http://localhost:82/containers/ after accessing http://localhost:82/cadvisor/
Is it possible to define application base context path to make cadvisor running behind custom nginx location? Any help will be appreciate
Hi @wololock, yeah this is a pain point we've been seeing a lot lately. I think it is time we tackle it. The suggestion so far has been to make links relative to allow for reverse proxying. This should work in your case too I believe.
I am closing this as a dup of #596, but I will try to find some time to tackle it this week. Or if you're up for it feel free to send a PR :) it should be a relatively small change and mostly localized to the pages/ directory.
This issue has been closed for a while but I just came across it trying to get this working. Is there documentation somewhere for how the relative path is set? The nginx config listed above does not work.
@wololock would you mind sharing a working nginx config? Thanks!
guys I'm trying to achive this and I'm one step from surrendering. I've tried this the zuul proxy
zuul config:
zuul:
routes:
cadvisor:
path: /cadvisor1/**
url: http://10.0.0.11:9002/
stripPrefix: false
It might be also a L8 Problem so I appreciate any hints.
is there maybe and option to the set for the "rootdir variable" in your code?
Looks like it is still broken, see https://github.com/google/cadvisor/pull/680
Most helpful comment
This issue has been closed for a while but I just came across it trying to get this working. Is there documentation somewhere for how the relative path is set? The nginx config listed above does not work.