proxy, google oauth, and connection refusal #676
Replies: 6 comments 7 replies
-
related: jenkinsci/google-oauth-plugin#62 jaredhanson/passport-google-oauth#54 |
Beta Was this translation helpful? Give feedback.
-
also related: googleapis/google-api-nodejs-client#1943, googleapis/google-api-nodejs-client#2345 |
Beta Was this translation helpful? Give feedback.
-
Interesting! Setting this in my proxychains.conf works!
huge thanks to @neorxna's comment in googleapis/google-api-nodejs-client#998 !!! |
Beta Was this translation helpful? Give feedback.
-
@iaincollins I'm having a similar issue here. My next application is deployed behind a corporate proxy. I learned that node doesn't recognise I need a way for requests made to Google by next-auth to go via the proxy. @archywillhe Could you share how you are starting the next server using proxychains? Are you using a custom server for next? Are you using pm2 or something like |
Beta Was this translation helpful? Give feedback.
-
I'm also interested in this issue. Seeing same behaviours in docker-compose using Bunkerised Nginx as proxy. I simply cloned https://github.com/nextauthjs/next-auth-example and added the following Dockerfile and docker-compose files next to it.
---
version: '3'
services:
proxy:
image: bunkerity/bunkerized-nginx:1.2.1
container_name: proxy
environment:
- AUTO_LETS_ENCRYPT=no
- ALLOWED_METHODS=DELETE|GET|OPTIONS|PATCH|POST|PUT
- BLOCK_ABUSERS=yes
- BLOCK_PROXIES=yes
- BLOCK_TOR_EXIT_NODE=yes
- BLOCK_USER_AGENT=yes
- CONTENT_SECURITY_POLICY=default-src http://local.domain.example https://fonts.googleapis.com https://fonts.gstatic.com https://*.googleusercontent.com 'self' 'unsafe-eval' 'unsafe-inline' ; frame-ancestors 'self'; form-action https://accounts.google.com 'self' ; block-all-mixed-content; sandbox allow-forms allow-same-origin allow-scripts; base-uri 'self';
- NEXTAUTH_URL=http://local.domain.example
- REDIRECT_HTTP_TO_HTTPS=no
- USE_REVERSE_PROXY=yes
- REVERSE_PROXY_URL_1=/
- REVERSE_PROXY_HOST_1=http://web:3000
- REVERSE_PROXY_URL_2=/api/auth
- REVERSE_PROXY_HOST_2=http://web:3000/api/auth
- SERVE_FILES=no
- SERVER_NAME=local.domain.example
- USE_BROTLI=yes
- USE_GZIP=yes
- USE_MODSECURITY=no
- USE_PROXY_CACHE=yes
healthcheck:
test: ["CMD-SHELL", "wget -O /dev/null http://localhost:8080 || exit 1"]
timeout: 10s
volumes:
- ./nginx/letsencrypt:/etc/letsencrypt
ports:
- 80:8080
- 443:8443
depends_on:
- web
networks:
- nextauth
restart: always
web:
build: "."
container_name: "web"
environment:
- NEXTAUTH_SITE=http://local.domain.example
- NEXTAUTH_URL=http://local.domain.example
- GOOGLE_ID=YOUR_ID
- GOOGLE_SECRET=YOUR_SECRET
networks:
- nextauth
restart: always
networks:
nextauth: I also tried with
and update NPM scripts: "scripts": {
"dev": "proxychains next",
"build": "next build",
"start": "proxychains next start"
}, Add proxychains.conf file at the root dir of the project, using "expected" IP address of my proxy:
The error I see is:
Although the login process can be accomplished, the session event fails. I checked the AI section in the example app and there is no payload for the session event (it did appear running the example without proxy): |
Beta Was this translation helpful? Give feedback.
-
I also had problems to use NextAuth behind corporate Proxy. Relates issue: #2509 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Your question
How not to run into
ECONNREFUSED
for google oauth when on a local server on top of proxychain i.e. a proxy conection?Details
I have tested my set up with Github OAuth and it works wonderfully. But for Google OAuth I keep getting
ECONNREFUSED
directly from Google server at216.58.200.45
.My VPN is deployed on an AWS EC2 instance. And locally I have set up a http proxy for my proxychains that connect to my VPN's client. I'm inside the GFW at the moment so without proxychains I will get timeout error instead.
I did some googling and this appears to be a known issue with testing google oauth locally behind a proxy. Just wondering if anyone knows any way to solve it. Thanks!
Feedback
Documentation refers to searching through online documentation, code comments and issue history. The example project refers to next-auth-example.
Beta Was this translation helpful? Give feedback.
All reactions