francescou / docker-compose-ui

web interface for Docker Compose
http://francescou.github.io/docker-compose-ui
MIT License
1.54k stars 228 forks source link

Path problem when running behind a reverse proxy #43

Closed riccardopedrielli closed 8 years ago

riccardopedrielli commented 8 years ago

Hi, I'm trying to run the container behind a reverse proxy, the url is like http://myserver/compose-ui/ and the proxy is configured to strip the compose-ui/ part before passing the request.

Everything is working fine, except for one link: + Create new project That link has a leading "/", so the resulting url is http://myserver/#/create instead of http://myserver/compose-ui/#/create.

I didn't play much with the ui yet, i'll update the issue if i find other absolute paths.

WTFKr0 commented 8 years ago

Hi,

I think the link here should be relative ` ng-href="#/create" `

francescou commented 8 years ago

@WTFKr0 thanks, it should be fixed now

francescou commented 8 years ago

@riccardopedrielli Hi could you please share the reverse proxy configuration? thanks

riccardopedrielli commented 8 years ago

Hi, i confirm the fix works.

Here are the configurations:

haproxy

global
    log 127.0.0.1 local0 debug

defaults
    mode    http
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    option  forwardfor
    option  redispatch

frontend testserver

    bind *:80

    acl compose-ui path_beg /compose-ui/
    use_backend compose-ui if compose-ui

    #other acls omitted

backend compose-ui
    reqrep  ^([^\ :]*)\ /compose-ui/(.*)  \1\ /\2
    server compose-ui compose-ui:5000 check

#other backends omitted

nginx

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    access_log          /var/log/nginx/access.log  main;
    sendfile            on;
    keepalive_timeout   65;

    server {
        listen              80;
        server_name         localhost;

        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-Host $server_name;
        proxy_set_header    Connection "";
        proxy_http_version  1.1;

        location /compose-ui/ {
            proxy_pass              http://compose-ui:5000/;
            auth_basic              "Docker Compose UI";
            auth_basic_user_file    /etc/nginx/.htpasswd;
        }

        #other locations omitted...
    }
}
francescou commented 8 years ago

Thank you!

I did some quick test withfrancescou/docker-compose-ui:latest and it seems to work fine.

In the next days I will add some documentation based on your configuration to describe how to use a reverse proxy with docker-compose-ui

WTFKr0 commented 8 years ago

For information I use traefik in front of all my webapp docker-compose-ui too Many reverse proxy solution are available, don't know if doc is needed in this project

francescou commented 8 years ago

@WTFKr0 yes you're right but I think it could be useful to have at least some docs on how to require basic authentication to access compose-ui

WTFKr0 commented 8 years ago

OK I see For that I used the h3nrik/nginx-ldap image in front of traefik :D Which assure a ldap basic http auth