nginx proxy pass to external url

后端 未结 1 660
天涯浪人
天涯浪人 2020-12-31 19:21

I have configured my nginx on amazon ec2 for the url www.example1.com . I need to proxy pass www.example1.com/blog to my blogging host www.example2.com/blog which is hosted

相关标签:
1条回答
  • 2020-12-31 19:33

    I'll give my answer here.

    The problem you meet is because $http_host in proxy_set_header Host $http_host; uses the host in your original request header, but what you really need is the host for www.example2.com. $proxy_host will use the host in your proxy_pass directive. see Embedded Variables at the bottom http://nginx.org/en/docs/http/ngx_http_proxy_module.html

    $proxy_host

    name and port of a proxied server as specified in the proxy_pass directive;

    And the reason it is not working for example1.com but www.example1.com I guess is because you didn't put the value example1.com in server_name directive.

    0 讨论(0)
提交回复
热议问题