Skip to content

cAdvisor + nginx in different then "/" context #667

Closed
@wololock

Description

@wololock

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions