Facebook oauth authentication is redirecting to localhost instead of to my domain
Asked Answered
C

1

2

While authenticating via OAuth, Facebook is redirecting to localhost instead of to my domain. I'm using django-allauth for facebook authentication. Someone at GitHub pointed out that the error could be in the Nginx configuration. I'm pasting my nginx configuration below:

server { # simple reverse-proxy
    listen       80;
    server_name  subdomain.domain.com;
    access_log   logs/site.access.log;

    # serve static files
    location ~ ^/static/  {
        root    /home/user_name/site_assets/;
        expires 30d;
    }

    # serve media files
    location ~ ^/media/(images|javascript|js|css|flash|img)/  {
        root    /home/user_name/site_assets/;
        expires 30d;
    }

    # pass requests for dynamic content to rails/turbogears/zope, et al
    location / {
        proxy_pass      http://localhost:8000;    
    }
  }

Could someone please clarify what I'm missing here?

Cribble answered 11/5, 2013 at 5:47 Comment(0)
C
6

I finally found it after a lot of tinkering around. The Nginx configuration should have this extra line. proxy_set_header Host $http_host; So the final Nginx configuration should look like:

server { # simple reverse-proxy
    listen       80;
    server_name  subdomain.domain.com;
    access_log   logs/site.access.log;

    # serve static files
    location ~ ^/static/  {
        root    /home/user_name/site_assets/;
        expires 30d;
    }

    # serve media files
    location ~ ^/media/(images|javascript|js|css|flash|img)/  {
        root    /home/user_name/site_assets/;
        expires 30d;
    }

    # pass requests for dynamic content to rails/turbogears/zope, et al
    location / {
        proxy_set_header Host $http_host;
        proxy_pass      http://localhost:8000;    
    }
}

Cribble answered 12/5, 2013 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.