# ktor


12/05/2020, 3:47 AM
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?

Joris PZ

12/05/2020, 8:31 AM
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


12/05/2020, 12:09 PM
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


12/05/2020, 12:53 PM
Ktor does everything for me except for PROXY protocol handling so, ironically, I need to keep a proxy behind my proxy.

Jorge R

12/06/2020, 11:59 AM
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.