Nginx reverse proxy on another web server with redirection

Hi all,
I have the problem with configuring nginx to perform proxy redirection
to
web server that appends some its local path to redirected address. As a
result I get url of my server (where nginx is running) but with path
(from
another machine) appended.

The configuration is:
location ~* ^/3rdparty/(.)___(.)(.*)(.*)$ {
proxy_pass https://$1.$2.$3.$4?$args;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}

When I type this:
http:// 192.168.237.208/3rdparty/192___168___237___222
I would expect content from here:
https://192.168.237.222
but I get attempt from server to get content from here - which doesn’t
exist:
http://192.168.237.208/3rdparty/192___168___237___222/users/sign_in

How to remove /users/sign_in sufix but to process that within nginx
server?

When I go directly to target server typing this:
https://192.168.237.222
I get redirected to
https://192.168.237.222/users/sign_in which brings the right content.

Thank you in advance for you comments/help!

Posted at Nginx Forum:

I have also added more detailed description with system diagram at:

Thank you!

Posted at Nginx Forum:

Quick sidenote, not scratching the surface of your problem:
I would have posted on ServerFault, not StackOverflow

B. R.