currently I have this as my proxy_pass
which works fine
location = /sms/resetpass {
proxy_pass http://xxx.xxx.xxx.xxx/api/resetpass;
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;
}
the above works fine but I figured if I want another proxy such as
location = /sms/sample1 {
proxy_pass http://xxx.xxx.xxx.xxx/api/sample1;
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;
}
then I have to make another location block
is it possible to do something like this?
location = /sms/something_here {
proxy_pass http://xxx.xxx.xxx.xxx/api/something_here;
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;
}
where something_here
means if I pass in any url into sms/blah
then the proxy_pass
would be api/blah
I tried to google something like proxy_pass with subpath
or something like that but doesn't seem to be what I need. So I am wondering if this is possible or I just didn't know the right word to find it?
Thanks in advance for any advices.
Use nginx
location
andrewrite
directives, something like this should be fine:don't forget to test it first.