'Adding location to the URL path in nginx

Nginx config:

server {
        listen 443 ssl;
        server_name xyx.com;


    location /name/ {
        rewrite    /name/([^/]+) /users?name=$1 break;
        proxy_pass http://127.0.0.1:80/;
}
} 

The above link works well if its just location / but with any other path like above location /name/ it fails.

We want the location path to be part of the url when requested.

All xyz.com/name url (and dependent) should proxy/redirect the users to http://127.0.0.1:80/name

Tried proxy_pass http://127.0.0.1$request_uri and other few stuff including rewrite and it didn't work.

Any suggestions appreciated - thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source