Rancher behind nginx reverse proxy location

Hi ,

Can someone help me , I’m tried to setup Rancher behind Nginx reverse proxy .
I already look into

https://rancher.com/docs/rancher/v2.x/en/installation/ha/helm-rancher/chart-options/#example-nginx-config

The problem is… it only work under " / " location … I tried to do something like this :

https://www.example.com/rancher

I have done some workaround using nginx … but i don’t think it’s good enough.

# Exact URI match to load the base rancher page without a redirect
location = /rancher {

    proxy_pass https://rancherhost:443; 
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
# Catch for all other rancher resources. Removes proxy URI before passing on
location /rancher {
    rewrite ^/rancher/(.*)$ /$1 break;

    proxy_pass https://rancherhost:443; 
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
# Catch for a stray rancher call that doesn't properly prepend the proxy URI
location ~ ^/(assets|v3|v3-public|translations|update-setting|engines-dist|login)/ {
    proxy_pass https://rancherhost:443; 
}

i’m using Rancher 2.x on docker container.