I would ask for help on my specific configuration: I have a Django application executed by gunicorn with an Nginx reverse proxy. Everything runs on the same Docker instance, run by Supervisord. Gunicorn runs on port 8000, Nginx runs on port 80. Note: If I run only the Django application (no Nginx proxy) everything works properly and OAuth from Google works.
The Nginx config is
server {
listen 80;
location /static/ {
alias /home/app/static/static_assets/;
}
location /media-files/ {
internal; # only the django instance can access this url directly
alias /home/app/media/media_assets/;
}
location / {
proxy_pass http://localhost:8000;
}
}
I am trying to use the above solution to make OAuth2 work with Google. With the original configuration the error is as follows:
Error 400: redirect_uri_mismatch The redirect URI in the request, http://localhost:8000/accounts/google/login/callback/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/${your_client_id}?project=${your_project_number}
If I add the configuration snippet I get the error below:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
Code: unknown, Error: HTTPSConnectionPool(host='accounts.google.com', port=443): Max retries exceeded with url: /o/oauth2/token (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f79207eb640>: Failed to establish a new connection: [Errno -2] Name or service not known')))