Google OAuth2 with node.js and Apache mod_proxy

783 views
Skip to first unread message

Patrick

unread,
Apr 11, 2012, 6:54:05 AM4/11/12
to oauth...@googlegroups.com
I set up an Apache VirtualHost to proxy my node.js App:

    <VirtualHost *:80>
        ServerName server.domain.com
        ServerAdmin admin example.com
        CustomLog /var/log/apache2/access_log combinedvhost
        ErrorLog /var/log/apache2/error_log

        ProxyPass / http://127.0.0.1:3000/
        ProxyPassReverse / http://127.0.0.1:3000/
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
    </VirtualHost>

When trying to log in via Google OAuth with passport.js I get a 502 error after the redirect:


502:

    Proxy Error
    
    The proxy server received an invalid response from an upstream server.
    The proxy server could not handle the request GET /auth/google/callback.
    
    Reason: Error reading from remote server
    
    Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 Server at server.domain.com Port 80

Why? Everything works perfect if I run it from my development machine on localhost.

Morten Hekkvang

unread,
Apr 11, 2012, 7:43:24 AM4/11/12
to oauth...@googlegroups.com
That is more likely to be a server setup error, than an oauth2 error.
Log your node.js setup and check how the request is received by your node.js server.
There is actually nothing very oauth-specific about the callback made.
I guess this might be some kind of error caused by url rewrites or the "?code=somereturncode" get parameter.
Another thing that might cause error is if the code contains invalid characters for your web-server setup.

br,
morten

Patrick

unread,
Apr 11, 2012, 8:13:30 AM4/11/12
to oauth...@googlegroups.com
Right, I was looking at the apache log all the time and forgot about node as it said proxy error.

Problem solved. Thanks!
Reply all
Reply to author
Forward
0 new messages