purpleworks / fleet-ui

Web based UI for fleet
http://fleetui.com/
MIT License
232 stars 39 forks source link

fleet-ui behind NGINX LBA #33

Open bchanan03 opened 8 years ago

bchanan03 commented 8 years ago

When fleet-ui is behind NGINX LBA:

I have a web site running on a docker container - where I want to hide behind NGINX LBA docker container. I started the web container and I can use curl to retrieve the index.html page the page retrieve .css, .js .html files by calling itself When I use the LBA and location / it works – but when I try to add a subfolder the web site calling the LBA fails to find resources (like .js .css .html) because of the subfolder (see image attached)

Example: I start a container running fleet-ui (https://github.com/purpleworks/fleet-ui) which expose the port 3000

When calling https://trust-authority-private.saas.lab/ui/#/
I get and error because the browse tries to retrieve https://trust-authority-private.saas.lab/views/layout.html?_cache=1440910986132633128 https://trust-authority-private.saas.lab/views/main.html?_cache=1440910986132633128 notice the missing sub-folder /ui/

I started nginx plus /and also nginx with the following nginx configuration:

worker_processes 4;

events { worker_connections 1024; }

http { include /etc/nginx/mime.types; default_type application/octet-stream;

log_format   main '$remote_addr - $remote_user [$time_local]  $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;
error_log   /var/log/nginx/error.log  debug;

sendfile        on;
keepalive_timeout  65;

include /etc/nginx/conf.d/*;
server {
    listen 443;
    ssl on;
    server_name         trust-authority.saas.lab;
    ssl_certificate     /ssl/cacert.pem;
    ssl_certificate_key /ssl/privkey.pem;

    location /admin/ {
       root /usr/share/nginx/html;
    }

    include /etc/nginx/location/*;
}

}

Inside /etc/nginx/location I added the following fleet-ui.conf location ~ ^/ui/.*$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_set_header Connection "Keep-Alive"; proxy_set_header Proxy-Connection "Keep-Alive"; proxy_http_version 1.1;

    proxy_pass http://fleet-ui.saas.lab:3000;
    rewrite ^/ui/(.*) /$1 break;

}

jmtsi commented 8 years ago

I had the same problem. This is fixed in #32, but it isn't merged yet.

bchanan03 commented 8 years ago

Any update here?