0

I need to proxy request From my server to another Two options should be realized

First:

From https://my-site.com/subjects/custom_id to https://another-site.com/subjects/custom_id

Example:

https://my-site.com/subjects/1 to https://another-site.com/subjects/1

https://my-site.com/subjects/2 to https://another-site.com/subjects/2

Nginx config (works fine):

  location ~ ^/subjects/?(.*) {
     resolver 8.8.8.8;
     proxy_pass https://another-site.com/subjects/$1$is_args$args;
   }

Second:

From https://my-site.com/subjects?code=custom_code to https://another-site.com/subjects?code=custom_code

Example:

https://my-site.com/subjects?code=1 to https://another-site.com/subjects?code=1

https://my-site.com/subjects?code=2 to https://another-site.com/subjects?code=2

How to write Nginx config for this case ?

Serhii Danovskyi
  • 385
  • 3
  • 17

1 Answers1

0

Fixed:

location ^~ /subjects {
     resolver 8.8.8.8;
     proxy_pass https://another-site.com/subjects;
}
Serhii Danovskyi
  • 385
  • 3
  • 17