API call redirects to incorrect port on docker

We have a custom docker image built with frappe_docker and we don’t use traefik (compose.noproxy.yaml override).

Our frontend container is published on port 8081. Nginx serves port 80, which redirects to a website.

We are using API calls for a method that we developped in Frappe and, for some unknown reason, the API call returns 404 error. We use Postman to execute the API call and the URL we are testing is something like http://server:8081/api/method/xact2.xact2.xmetodos.calcula_multa_mora

After some investigation, we saw in frontend container logs that the API call gives a HTTP 301 redirect response (log below):
[02/Jun/2023:00:43:16 +0000] “GET /api/method/xact2.xact2.xmetodos.calcula_multa_mora HTTP/1.1” 301 169 “-” “PostmanRuntime/7.29.0”

In the website served by Nginx (port 80) we created a file named xact2.xact2.xmetodos.calcula_multa_mora in the website path /api/method/ with “test” text inside it and, surprise, the API call now returns “test” as result and HTTP 200 status!

So, anyone could help us to understand why Frappe is removing the 8081 port in API call ? Why does it redirect to port 80? @revant_one do you have any clue about this?

This only happens with docker. We have another frappe-bench development site (without docker) in port 8001 in the same server, where this API works correctly.

1 Like

No clue about it. I’ve not used setup like yours. I can’t help much.

I use dockerswarm.rocks in case of budget setup. I use client provisioned k8s for enterprise setup.

Share your proxy configuration may be someone else with such setup may help.

1 Like