Q:

nginx proxy - aws emr cluster [multiple UIs]

Description: When launching an EMR cluster each application is configured to expose its UI.
Goal: Access the UIs through Nginx using friendly URLs without port number
Details:

Each UI is on a different port
Basic Authentication (htpass)
Some UIs redirect you to the private-dns-record of the EMR master (can fix them manually, need Nginx to do it)
UI Ports: 8088,8890,8888,18080,50070

What has been done?
A) Following this article we are able to access Zeppelin
B) We tried to modify that configuration to allow more locations
    The logic behind that was that by doing that we could access the nginx with '/somename' and be redirect using 'upstream' to the relevant port on the EMR master but sadly it does not work.
location /hadoop {
  proxy_pass hxxp://hadoop
} 

C) We tried rewriting rules but once we put
rewrite ^/hadoop(.*)$ /$1 permenant;
Under /somename it actually goes to:
location /
Question: How can we use simple friendly URLs such as hxxp://mynginx/hadoop to access the UIs?

Example: http://nginx/app should redirect to http://upstream-server:8088

A:

So, if I understood correctly, you have a location block like this:
location /hadoop {
    rewrite ^/hadoop(.*) /$1 permanent;
    proxy_pass http://hadoop;
}

The rewrite statement above sends a 301 Moved Permanently response back to the browser, with the rules you have written. Therefore the user is redirected to the / URI when you access /hadoop.
Most likely you want this:
location ~ ^/hadoop(.*)$ {
    proxy_pass http://hadoop$1;
}

Here we capture the part after /hadoop into a variable, and then use that variable with the proxy_pass destination.
However, you still need to fix the URLs the Hadoop backend is sending back to the client in its HTML code, otherwise it is not returning URLs with /hadoop prefix.

