I'm always running my Kotlin web stuff behind ngin...
# ktor
r
I'm always running my Kotlin web stuff behind nginx, but the nginx seems to do nothing for me. It's just more annoying configuration. Do you think I could run Ktor on ports 80 and 443 and have it be the main web server?
j
Well you certainly could technically, no problem at all. But you'd have to make sure that everything your current frontend server currently does is taken care off by Ktor. Could be anything - static file serving, security filters, TLS offloading
c
nginx is probably more performant at tls. also you need some firewall rules to forward port 80 to ktor because you probably don’t want ktor running as root. I think running ktor behind nginx is a good idea
🙌 1
d
Ktor does everything for me except for PROXY protocol handling so, ironically, I need to keep a proxy behind my proxy. https://youtrack.jetbrains.com/issue/KTOR-500
j
I would say that dividing responsibilities will help on deployment later on. If for some reason you need to deploy to another server that already has ports 80-443 taken, you will need to adapt your Ktor setup. Also, if you want to deploy multiple frontend instances, you will need a load balancer. You cannot instantiate multiple Ktor instances in the same 80-443 port, you will use something like Nginx to receive requests and distribute them along all your frontend instances, with some load balance strategy. Each instance will need to have its own port, so think about Ktor instance port as a dynamic value.
227 Views