We have an embedded URL in our mobile project like https://www.example.com/api/v1. We can not change this address. We are moving our project to different subdomain so that in nginx we are trying to reverse proxy for reaching out this address.
New address will be https://api.example.com/api/v1 and when mobile project come to https://www.example.com/api/v1 nginx will reverse proxy to > https://api.example.com/api/v1
any body have an idea? Thanks a lot.
location ~/api(.*)$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass https://api.example.com/api/$1;
}
This method worked for me.
location ~ ^/somepath/?(.*) {
resolver 192.xxx.xxx.xxx;
proxy_pass https://api.example.com/$uri$is_args$args;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With