title: Omniauth Nginx Unicorn callback to wrong host URL
body: <p>I've deployed a Rails app to a VPS server, and I'm using the Nginx/Unicorn combo, everything works fine, except that for some reason beyond my understanding, the Omniauth callbacks redirect wrong, </p>
  
  <p>ie.</p>
  
  <pre><code>http://unicorn/users/auth/linkedin/callback?oauth_token=95218ed3-b426-45ab-b022-693d2a2447cb&amp;oauth_verifier=25955
  </code></pre>
  
  <p>it should instead be:</p>
  
  <pre><code>http://my-real-domain.com/users/auth/linkedin/callback?oauth_token=95218ed3-b426-45ab-b022-693d2a2447cb&amp;oauth_verifier=25955
  </code></pre>
  
  <p>What's wrong? why is the callback using the name of the upstream defined in nginx?</p>
  
  <pre><code>upstream unicorn {
    server unix:/tmp/unicorn.todo.sock fail_timeout=0;
  }
  
  server {
    listen 80;
    listen [::]:80 ipv6only=on default_server;
  
    root /home/deploy/work/project/current/public;
    index index.html index.htm;
  
    server_name my-real-domain.com;
  
    try_files $uri/index.html $uri @unicorn;
  
    location @unicorn {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Client-IP $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_pass http://unicorn;
    }
  
    error_page 500 502 503 504 /500.html;
  
    location ~ ^/assets/ {
      expires 1y;
      add_header Cache-Control public;
  
      add_header ETag "";
      break;
    }
  }
  </code></pre>
  
  <p>Could you please help me? I need to know how to overcome this wrong redirection.</p>
  
  <p>Thanks in advance!</p>