D
Dokploy4w ago
AlexN

Unable to fetch data from GCP

This is a sort of urgent. So, I am unable to fetch data from Google Cloud Platform using Dokploy. Example; https://taskuri-nextjs-j7ieak-204699-91-99-89-142.traefik.me/api/get-user-ip/ - if (E) it means Error. This is hosted on Hetzner VPS, it gives me an error. If I curl from VPS (not via NextJS app which is routed through Traefik) then it works. This means that Hetzner VPS Public IP isn't banned by GCP. Could it be a problem with the NextJS app? No, because the same hosted on Vercel works fine. Working live example: https://taskuri.ro/api/get-user-ip/ I attached an Image to show proof that curl from VPS works.
No description
39 Replies
AlexN
AlexNOP4w ago
Also, I did curl via the Docker Terminal of the app and it did curl successfully.
AlexN
AlexNOP4w ago
So if there is nothing wrong with Docker container, then why NextJS API route doesn't work via Dokploy but the same code and deployment works via Vercel?
No description
Henrik
Henrik4w ago
You don't have a valid cert for that domain
No description
Henrik
Henrik4w ago
Certificates | Dokploy
Configure your certificates to secure your applications.
AlexN
AlexNOP4w ago
Hi Henrik, ty for your prompt reply. I don't think its an SSL issue. I assigned Dokploy to another domain so; https://taskuri.md/api/get-user-ip - Dokploy https://taskuri.ro/api/get-user-ip - Vercel (E) Means it doesn't work
Henrik
Henrik4w ago
I'll have to test something real quick
AlexN
AlexNOP4w ago
I initially thought Hetzner's IPv4 addresses were getting banned, but they aren't
Henrik
Henrik4w ago
What header are you extracting for the IP? Is it X-Forwarded-For?
AlexN
AlexNOP4w ago
sec my exact code is
const ipAddress =
req.headers.get("cf-connecting-ip") ??
req.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ??
"178.168.92.137";
const ipAddress =
req.headers.get("cf-connecting-ip") ??
req.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ??
"178.168.92.137";
AlexN
AlexNOP4w ago
but again I don't think its with header. Because I can see their IP
No description
Henrik
Henrik4w ago
Sure those are case insensitive?
AlexN
AlexNOP4w ago
console.log looks like its giving me the IP
No description
AlexN
AlexNOP4w ago
so likely yes
Henrik
Henrik4w ago
Hard to debug from those symptoms. Check if your program has problems calling out to other APIs. A wild long shot is outdated CA files in the container, but I doubt it
AlexN
AlexNOP4w ago
Nope, I even put it behind Cloudflare SSL for almost a week and same stuff
Henrik
Henrik4w ago
It's doesn't sound like an ingress issue, but it's your outgoing connection to ipinfo You're getting the header you want to have
AlexN
AlexNOP4w ago
Yep If you want you can use my vps to test yourself I am using the app.dokploy.com to manage the VPS
Siumauricio
Siumauricio4w ago
Welcome to vendor lock, I also think it's something about how docker networks handle reading the ip of a request
Henrik
Henrik4w ago
You sure that's the issue?
Siumauricio
Siumauricio4w ago
I really think it's something like docker handling networks, I remember I had a similar problem I think someone here had solved this problem.
AlexN
AlexNOP4w ago
Idk if you guys see my Projects, but if you don't and is of any help i am using Nixpacks
Siumauricio
Siumauricio4w ago
it shouldn't affect what kind of builder you are using, it's more related to traefik and docker
Henrik
Henrik4w ago
It could be Traefik if it was an ingress issue, it doesn’t sound like that’s the issue Get a shell inside the container and check if the service is reachable from there
AlexN
AlexNOP4w ago
sec
AlexN
AlexNOP4w ago
No description
AlexN
AlexNOP4w ago
I did it also via SSH (shelled into container) (not Dokplay UI) and service is reachable
Henrik
Henrik4w ago
That would give the same outcome, but I understand the try everything mentality. I’m kinda out of ideas right now
AlexN
AlexNOP4w ago
My only curiosity at this point is to see whether you could reproduce it on your end I can give you my code and see whether you get this eror with Hetzner (or other VPS) and not Vercel
Henrik
Henrik4w ago
Sure
AlexN
AlexNOP4w ago
add in /src/app/api/get-user-api/route.ts
AlexN
AlexNOP4w ago
So take this API route, and deploy the app on both Vercel and a Dokplay VPS and let us know I am not going to sleep 😄 but wait for this
AlexN
AlexNOP4w ago
if its of any help: an hour earlier before the timeout error I used to get HTTP 403. Their docs say: https://community.ipinfo.io/t/getting-403-forbidden-when-accessing-the-ipinfo-api-and-website/303
IPinfo Community
Getting 403 forbidden when accessing the IPinfo API and website
If a user receives a 403 status when accessing our website or API, it means that our servers understood their request but refused it. This error can occur for a number of reasons. In some instances, this may be due to international regulations and infrastructure policies. Our cloud infrastructure is based on Google Cloud Platform (GCP), whic...
Henrik
Henrik4w ago
Worked like a charm
No description
Henrik
Henrik4w ago
This was also done with a Hetzner VPS
AlexN
AlexNOP4w ago
I’ll start fresh as well in a couple of hours. Thank you so much for trying out
AlexN
AlexNOP4w ago
Hi Henrik, again it's me. https://github.com/alexclinky/ipinfo <- this is the GitHub repo and it still doesn't work on my setup. http://taskuri-ipinfo-ypxahg-5e5696-91-99-89-142.traefik.me/api/get-user-ip - Dokploy (doesn't work)
GitHub
GitHub - alexclinky/ipinfo
Contribute to alexclinky/ipinfo development by creating an account on GitHub.
AlexN
AlexNOP4w ago
and again curl from same docker container works now I am even more confused. Why does it work in your Dokploy config, and not mine...
Henrik
Henrik4w ago
It looks awfully similar to what I deployed. I also used nixpack.
AlexN
AlexNOP4w ago
Henrik, if you dont mind can you give me your route.ts code?:D I made changes to my git repo to keep on trying to figure out what's happening. What I found out through my reproduction git repo tests; 1. await Promise - doesn't work on Dokploy, they are simply ignored 2. console.log in nextjs server components doesn't get reported in Dokploy logs menu tab - simply ignored 3. If I just put the IP address (without taking it from Headers) then it successfully fetches from ipinfo.io. As soon as I add Headers in server side code, ipinfo fails. (I think this is the reason why you were able to see your IP info, because you hard coded it)

Did you find this page helpful?