I have setup a Ktor application and deployed it on an RPi-4. I have a Docker image that I am building locally by extending balenalib/raspberrypi3-openjdk:8-jdk since there is no JDK one for RPi-4 that I have found.
The application is deployed correctly, but needs an iptables port forwarding in order to redirect the port 80 to port 8080, since you can not listen on port 80 due to Linux permissions for ports lower than 1024, which makes Netty crash with permission denied.
Thus far everything is fine, although there seems to be a load balancer in front of the public URL of a device, which causes repeated redirects, causing the application to not respond. On several load balancers or reverse-proxies there seems to be special request headers preventing those issues and I was able to resolve this issue in Google Cloud Run for example, by utilizing Ktorβs feature https://ktor.io/quickstart/faq.html#infinite-redirect
This seems to not be the case for balenaOS though, since the redirects do not stop. Is there anyone who can give me a hint on what I might be missing?
Can you please try as well iptables -P FORWARD ACCEPT as something like that is often needed when running under balenaOS compared to other distributions which have less restrictive default forward policy and see whether this will solve the issue for you?
Hi there, just to rewind a bit on the conversation, what is the reason for you needing to modify the iptables? In Docker you can map the hostOS port to a container port, so you can do something like 80:8080, and run your web application on port 8080. Is this a multicontainer application? You can see how the ports are mapped here https://github.com/balenalabs/multicontainer-getting-started/blob/master/docker-compose.yml in the docker-compose file. Let us know if that solves your issue.
Will try that as well. Is there a way to revert the iptables rules though in order to be sure, that the docker compose rule works due to port exposure?
@sradevski@majorz@nazrhom Thank you all for your help! I went with the docker-compose approach and it worked like a charm I am quite grateful for your responsiveness!