0

I have original url like https://sourceURL/api/fcst/login/login?ProCode=420000, I want config the proxy_pass let it forward to https://targetURL/pestiot/api/fcst/login/login?ProCode=420000。 Here is my current config

location ~ ^/api {
    if ($request_uri ~* "ProCode=420000") {
        rewrite ^(/api/fcst.*)$ /pestiot$1 break;
        proxy_pass https://targetURL;
        break;
    }
}

It seems this always can't work. The pestiot doesn't exist in final target whole url. Currently,

  • when I use https://sourceURL/api/fcst/login/login?ProCode=420000 the response is 403 Forbidden.
  • But https://targetURL/pestiot/api/fcst/login/login?ProCode=420000 works
  • and https://targetURL/api/fcst/login/login?ProCode=420000 response 404

1 Answer 1

0

This config can work. My mistake is this

proxy_set_header Host $http_host;

Since I have proxy to the originalUrl once, so the this sentence should be

proxy_set_header Host $proxy_host;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.