Django Social Auth重定向到带有端口号的url [英] Django Social Auth redirect to url with Port number

查看:129
本文介绍了Django Social Auth重定向到带有端口号的url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能为我提供帮助,因为我正在努力从django_social_auth应用重定向到Facebook.

I hope somebody can help me because im struggling with the facebook redirects from the django_social_auth app.

问题在于,它使我无法重定向到包含的端口号:

The problem is that it keeps me redirecting with the port number included:

  1. http://mywebsite.com/login/facebook
  2. http://mywebsite.com:8080/complete/facebook/
  1. http://mywebsite.com/login/facebook
  2. http://mywebsite.com:8080/complete/facebook/

问题是我正在为Django项目运行Nginx/apache配置.

The thing is that i'm running a Nginx/apache configuration for my django project.

  • 用于端口上的静态/媒体的Nginx,位于端口80和8080的代理路径上
  • 端口8080上的Apache

我研究了social_auth代码,似乎它使用了request.get_host() 确定重定向(显然包含端口)

I digged into the social_auth code and it seems that it uses request.get_host() to determine the redirects ( which obviously contains the port )

处理这种情况的最聪明的方法是什么?

What would be the most clever way to handle the situation ?

  • 重新配置apache和nginx并切换其端口?
  • 写出剥夺端口号的中间件吗?

非常感谢

推荐答案

感谢查理(Charlie)向我指出了正确的方向.

Thank you to Charlie who pointed me to the right direction.

我唯一要做的就是将此行添加到我的nginx服务器配置中:

The only thing i had to do was add this line to my nginx server config:

proxy_set_header Host $host;

这就像Django的设置

and this like to the django settings

USE_X_FORWARDED_HOST = True

现在可以正常使用

这篇关于Django Social Auth重定向到带有端口号的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆