0

我将站点从已停用的OpenShift v2转移到AWS上的LightSail。我已经在LightSail上运行该应用程序,并在外部转发,其格式为localhost:3333。我能够使用site-url.com反向代理发送127.0.0.1作为URL,而不是外部site-url.com到oauth回调

拉起该网站但试图登录到应用程序(使用Passport Facebook)。回调URL是越来越设置为127.0.0.1,而不是白名单(脸谱DEV)www.site-url.com

https://www.facebook.com/dialog/oauth?response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A3333%2Fauth%2Fwww.site-url.com%2Fauth%2Ffacebook%2Fcallback&scope=email&client_id=XXX

相关的登录代码:

const appUrl = "www.site-url.com"; 
const callbackURL = appUrl + "/auth/facebook/callback"; 
passport.use(new FacebookStrategy({ 
       clientID: clientID, 
       clientSecret: clientSecret, 
       callbackURL: callbackURL, 
       profileFields: ['id', 'displayName', 'email'] 
     }, 

... 

app.get('/auth/facebook', 
     passport.authenticate('facebook', { scope: ['email'] })); 

app.get('/auth/facebook/callback', 
     passport.authenticate('facebook',{ 
      successRedirect: appUrl + '/profile', 
      failureRedirect: appUrl + '/?login-failed'} 
     )); 

我加appUrl,试图通过服务器来解决它码。不过,我有一种感觉,Apache会更适合解决这个问题。

我设置了代理服务器,以下these instructions,并试图127.x/site-url.com

ProxyPass/http://127.0.0.1:3333/ 
# ProxyPass/http://www.site-url.com/ 
ProxyPassReverse/http://127.0.0.1:3333/ 
# ProxyPassReverse/http://www.site-url.com/ 

任何人的所有变化有什么想法?

+1

尝试在'ProxyPass'之前添加'ProxyPreserveHost On'' –

+0

谢谢@DusanBajic,这正是需要的:) –

回答

1

打开PreserveHost解决了这个问题,Facebook的现在接收到正确的回调URL

PreserveHost:

ProxyPreserveHost On 
ProxyPass/http://127.0.0.1:3333/ 
ProxyPassReverse/http://127.0.0.1:3333/ 

Apache的配置:

vim /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf

附加: Include "/home/bitnami/conf/httpd-app.conf

Start up the app using screen避免在SSH进程被终止时关闭。也许试试nodemon for resiliency

谢谢,@DusanBajic!