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

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
Solution:
is nextjs listening on ipv6? if not, it needs to be as the private network is ipv6 only
Jump to solution
11 Replies
Percy
Percyβ€’6mo ago
Project ID: 7fc7bc42-6e0c-449e-92b2-6706b93a0592
nightmarebegood
nightmarebegoodOPβ€’6mo ago
7fc7bc42-6e0c-449e-92b2-6706b93a0592
Solution
Brody
Brodyβ€’6mo ago
is nextjs listening on ipv6? if not, it needs to be as the private network is ipv6 only
nightmarebegood
nightmarebegoodOPβ€’6mo ago
but is is working, it just stops working when I redeploy only the nextjs if it was nextjs ipv6 not listening, it would have never worked and thank you for your help πŸ™‚
Brody
Brodyβ€’6mo 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.
nightmarebegood
nightmarebegoodOPβ€’6mo ago
No problem, it was not urgent and I am between projects Thanks for your follow up Brody If you have a template with caddy and with a username password that will work, I am all in or if we only need a simple nginx to not cache dns, I will try to find something there first
Brody
Brodyβ€’6mo ago
I'll see if I can whip something up for caddy
nightmarebegood
nightmarebegoodOPβ€’6mo ago
thanks πŸ™‚
Brody
Brodyβ€’6mo ago
hey, sorry it took me longer than id like to get to this, but i have a working drop in replacement now - https://github.com/brody192/railway-caddy-basic-auth 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
nightmarebegood
nightmarebegoodOPβ€’6mo ago
Wonderful thank you so much. I will try and revert back to you πŸ™‚
Brody
Brodyβ€’6mo ago
sounds good!
Want results from more Discord servers?
Add your server