0

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://;
}
Jiho
  • 338
  • 1
  • 6
  • 14

1 Answers1

1

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/

Jiho
  • 338
  • 1
  • 6
  • 14