3 ms·
Are people who are using Go (for web apps) using it with Apache or Nginx? Or is every go app just using a DIY server? I'm genuinely curious
by jayflux 11y ago
Are people who are using Go (for web apps) using it with Apache or Nginx?
Or is every go app just using a DIY server? I'm genuinely curious
- chvid 11y agoThat is a good question; I also wonder what a real world production environment looks like. A Go program listening directly to port 80 running as root? What about virtual hosting, https, load balancing and so on?
- andreynering 11y agoActually, you choose. I like to use https://caddyserver.com/ https://caddyserver.com/ as reverse proxy for the easy setup and buildin Let's Encrypt support. You can also use Apache or Ngixn if you want. But you can also bind directly to port 80 if it's a simple app.
- Vendan 11y agoI wrote my own reverse proxy in Go to route stuff to other Go processes based on hostnames, and made it so I could listen to port 80 without root. At first, that was via `setcap 'cap_net_bind_service=+ep'`, but that was a little fragile, as I'd have to remember to do that on every recompile, so I switched to just listening to port 8080 and using iptables to forward 80 to that.
- dejawu 11y agoLike Vendan, I run my Go webapps on port 8080 (so I don't need root) and then have a very simple HAProxy setup that forwards port 80 to port 8080. Then I write a simple service for my Go app so I can control it with systemctl.