Nginx proxy with password timeout after each redeploy of my nextjs application
juliennix
PROOP

2 years ago

Hello all,
I am using the following https://github.com/toyjack/railway-nginx-basic-auth.
It is working with this template being public, the nextjs is internal. When I redeploy, the website become unavailable:

2024/05/28 16:23:21 [error] 31#31: *1156 upstream timed out (110: Operation timed out) while connecting to upstream, client:
192.168.16.6, server: _, request: "GET /infinity/dashboard/ HTTP/1.1", upstream: "http://[fd12:4c67:9587:0:4000:4:91e8:210f]:3000/infinity/dashboard/", host: "appname.up.railway.app"

Do you know what could be the issue?

Thanks

15 Replies

juliennix
PROOP

2 years ago

7fc7bc42-6e0c-449e-92b2-6706b93a0592


2 years ago

is nextjs listening on ipv6? if not, it needs to be as the private network is ipv6 only


juliennix
PROOP

2 years ago

but is is working, it just stops working when I redeploy only the nextjs


juliennix
PROOP

2 years ago

if it was nextjs ipv6 not listening, it would have never worked


juliennix
PROOP

2 years ago

and thank you for your help 🙂


2 years ago

yep that's fair, I didn't hear back so I marked as solved, my apologies.

the issue here is that nginx is using a caching dns resolver, so when you deploy the other service it gets a new ipv6 ip and thus the ip that nginx has in its cache is incorrect and that's where you are getting the error.

the fix for this is to configure nginx to not cache dns, or the better option would be to switch to caddy instead where no extra configurations are needed to disable dns cache.


juliennix
PROOP

2 years ago

No problem, it was not urgent and I am between projects


juliennix
PROOP

2 years ago

Thanks for your follow up Brody


juliennix
PROOP

2 years ago

If you have a template with caddy and with a username password that will work, I am all in


juliennix
PROOP

2 years ago

or if we only need a simple nginx to not cache dns, I will try to find something there first


2 years ago

I'll see if I can whip something up for caddy


juliennix
PROOP

2 years ago

thanks 🙂


2 years ago

hey, sorry it took me longer than id like to get to this, but i have a working drop in replacement now -

simply fork this, then replace your auth services' source with your fork.

this caddy basic auth now also has a /health-check endpoint you can use to set a health check in the service settings


juliennix
PROOP

2 years ago

Wonderful thank you so much. I will try and revert back to you 🙂


2 years ago

sounds good!


Loading...