Python-social-auth requires real hostname when using apache+gunicorn

After a successful authentication using google-oauth2 with the python-social-auth tool, the client gets redirected to a ../complete/ page. However, after forwarding all non-static traffic from the apache to a local gunicorn server, the redirection url points to http://localhost:8000/complete rather than to the real website. This can be easily fixed by enabling the ProxyPreserveHost setting in the apache config:

<VirtualHost *:80>
        ServerAdmin ...
        ServerName ...
 
        Alias /static /.../static
 
        DocumentRoot ...
 
        <Directory ...>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
 
        ProxyPreserveHost on
 
        RewriteEngine on
        RewriteRule ^/static/.* - [L]
 
        # Django is run via gunicorn. So proxy the rest.
        RewriteRule ^(.*) http://localhost:8000$1 [P]
</VirtualHost>

VN:F [1.9.22_1171]
Rating: 5.0/10 (1 vote cast)
Python-social-auth requires real hostname when using apache+gunicorn, 5.0 out of 10 based on 1 rating

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Wir benutzen Cookies um die Nutzerfreundlichkeit der Webseite zu verbessen. Durch Deinen Besuch stimmst Du dem zu.