title: Change Host header in nginx reverse proxy
body: <p>I am running nginx as reverse proxy for the site example.com to loadbalance a ruby application running in backend server. I have the following <code>proxy_set_header</code> field in nginx which will pass host headers to backend ruby. This is required by ruby app  to identify the subdomain names.</p>
  
  <pre><code>location / {
      proxy_pass http://rubyapp.com;
      proxy_set_header Host $http_host;
  }
  </code></pre>
  
  <p>Now I want to create an alias <code>beta.example.com</code>, but the host header passed to backend should still be <code>www.example.com</code> otherwise the ruby application will reject the requests. So I want something similar to below inside location directive.</p>
  
  <pre><code>if ($http_host = "beta.example.com") {
      proxy_pass http://rubyapp.com;
      proxy_set_header Host www.example.com;
  }
  </code></pre>
  
  <p>What is the best way to do this?</p>