1

I'm currently migrating from Apache to Nginx.
I want to set http-https apache ProxyPassReverse to Nginx.
My current Apache setting is below.

<Location /abc >
  RequestHeader set Host "sample.com"
  ProxyPass              http://sample.com/abc keepalive=On retry=0
  ProxyPassReverse       https://sample.com/abc
</Location>

I tried in nginx like below, but it shows 302 code, and then becomes timeout(never returns)..

upstream sample {
  keepalive 32;
  keepalive_timeout 5s;
  server sample.com;
}

location /abc {
  proxy_pass http://sample/abc;
  proxy_set_header Host sample.com;
  proxy_redirect http:// https://;
}

1 Answer 1

2

I solved this problem with adding X-Forwarded settings.

location /abc {
  proxy_pass http://sample/abc;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host sample.com;
  proxy_redirect http:// https://;
}

I referred to this page.
https://www.nginx.com/resources/wiki/start/topics/examples/likeapache/

Sign up to request clarification or add additional context in comments.

1 Comment

That URL is now dead. For the referenced example, look here: github.com/nginxinc/nginx-wiki/blob/master/source/start/topics/…

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.