使用Passport-google代理

时间:2013-03-26 10:24:48

标签: node.js iis-7 proxy openid passport.js

我正在使用Passport-google登录example.com:3000中的用户。它很棒。但是,如果我把Node.js服务器放在代理(IIS7;不要问为什么,我不得不),并在example.com(而不是example.com:3000)访问我的网站,我可以'使用Passport-google登录。我在IIS中的RewriteRule:

Pattern (.*) 
{HTTP_HOST} Matches myserver.com
{SERVER_PORT} Does not match 3000
Rewrite URL: http://127.0.0.1:3000/{R:1}

我得到的错误:

Cannot GET /accounts/o8/ud?

我也有与Passport-twitter和Passport-facebook相同的问题。

我想我应该在IIS中设置一些其他规则,或者在Passport.js或OpenID中设置一些代理设置,但尚未弄清楚。有什么想法吗?

1 个答案:

答案 0 :(得分:1)

IIS代理配置错误。在应用程序请求路由(ARR)/服务器代理设置Reverse rewrite host in response headers已打开,因此当护照发送302并且标头中的位置设置为https://www.google.com/accounts/o8/...时,IIS代理将其替换为http://myserver.com/accounts/o8/...。这当然是一个无效的链接。