here is what I want:
uri like: http://mydomain.xxx:33380/client001
should be redirected to http://10.8.51.21:3780/ui
in VPN.
uri like: http://mydomain.xxx:33380/client001/adm
should be redirected to http://10.8.51.21:3780
in VPN.
My config here:
map $clientname $back_srv {
"client000" "10.8.50.1";
"client001" "10.8.51.21";
"client002" "10.8.51.25";
default "mydomain.xxx";
}
server {
listen 33380;
location ~ "^/(client[0-9]{3})|/(adm)$" {
set $clientname $1;
set $adm $2;
set $svc_pfix "/ui";
if ($adm = "adm") {
set $svc_pfix "";
}
set $svc_port "3780";
rewrite ^(.*)$ $svc_pfix break;
proxy_pass http://$back_srv:$svc_port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
When I go to http://mydomain.xxx:33380/client001
nginx redirects to http://mydomain.xxx:33380/ui
and show 404 error. Look like proxy_pass doesn't works.
I tested other simple config without regexp and map, it works properly:
server {
listen 888;
location /svc_loc {
rewrite ^/svc_loc /(.*) /$1 break;
proxy_pass http://10.8.51.21:3780;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Any ideas?