5 ms·
I much prefer to serve Go applications through an NGINX reverse proxy. It deals with a lot of stuff for you (static assets, SSL, logging, etc.) and lets you fo
by eljimmy 10y ago
I much prefer to serve Go applications through an NGINX reverse proxy.
It deals with a lot of stuff for you (static assets, SSL, logging, etc.) and lets you focus on developing your application rather than re-inventing the wheel.
Would be a good idea to add in a section on configuring that type of setup.
- thewhitetulip 10y agoI am sorry for sounding naive, but I have never used a reverse proxy before, I'll work on it though and add a chapter as soon as possible. It'd be great if you can provide me some pointers :)
- nkozyra 10y agoNot many pointers needed, a simple reverse proxy to your local Go app will provide all of the good, mature stuff that NGINX provides, most noteworthy good, simple plug-and-play logging: location / { proxy_pass http://127.0.0.1:8088; } This of course proxies everything to your Go app; you'd probably want to let NGINX handle static assets as well.
- brightball 10y agoJust think of it as a load balancer. Just something that sits in front of your application and gives you the opportunity to determine how to handle things before they get to your application. Usually things like serving images, css, automatically compressing them, automatically compressing other traffic, domain redirects, ssl, etc. Helps keep your application focused although I realize it can be tempting to just do all that inside of go since it's somewhat good at it.
- deleted 10y ago[deleted]
- caleblloyd 10y agoAnother argument in favor of running NGINX in front of a Go webserver is that Golang's web server doesn't do any compression by default. It's possible to add in Go via a middleware but it's very simple to configure in NGINX. Also, NGINX's C implementation of compression should be faster than a pure Go implementation.
- wanda 10y agoWith Caddy[0] around, the only thing that keeps me tied to nginx is its performance and tried-and-tested-ness. Waiting to see someone do some detailed benchmarks on Caddy before I commit to it for production stuff, because I'm too busy and too lazy to do them myself and I have a while left on my paid TLS certs. I mention Caddy because it includes LetsEncrypt and HTTP/2 out of the box — and is written in Go. [0] https://caddyserver.com https://caddyserver.com
- ckluis 10y agoCaddy also just received one of the Mozilla OSS grants/awards.
- colemickens 10y ago"the only thing" keeping you with nginx is virtually the most important thing that I want out of my (reverse proxying) web server.
- vbtechguy 10y agoAsk and you shall receive Caddy 0.8 and 0.9 benchmarks against Nginx 1.9.7 and 1.11.3 over 2 periods Dec 2015 and Aug 2016 https://community.centminmod.com/threads/caddy-http-2-server-benchmarks.5170/ https://community.centminmod.com/threads/caddy-http-2-server...
- waits 10y agoHaproxy is great for this as well. I use it just for SSL offloading and compression, and leave the static files to Go.