title: nginx proxy pass to external url
body: <p>I have configured my nginx on amazon ec2 for the url <a href="http://www.example1.com" rel="nofollow noreferrer">www.example1.com</a> . I need to proxy pass <a href="http://www.example1.com/blog" rel="nofollow noreferrer">www.example1.com/blog</a> to my blogging host <a href="http://www.example2.com/blog" rel="nofollow noreferrer">www.example2.com/blog</a> which is hosted on bluehost ( shred hosting ) without changing the url in browser. Is it possible ?</p>
  <p>I tried many different combinations like</p>
  <pre><code>location /blog {
      proxy_pass http://www.example2.com;
      proxy_set_header Host $http_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  </code></pre>
  <p>without any luck.</p>
  <p>I could see in the log that nginx is trying to map to the IP instead of the domain which is the reason for the failure as shared hosting cannot recognize the ip but domain name.</p>
  <p>Any input/help will be really appreciated.</p>