在用于Go的Web服务器前使用Nginx有什么好处? [英] What are the benefits of using Nginx in front of a webserver for Go?

查看:354
本文介绍了在用于Go的Web服务器前使用Nginx有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些返回JSON数据的Web服务,这些用户有很多用户.

I am writing some webservices returning JSON data, which have lots of users.

与仅使用go http服务器相比,在服务器前端使用Nginx有什么好处?

What are the benefits of using Nginx in front my server compared to just using the go http server?

推荐答案

这要视情况而定.

开箱即用,将nginx放在前面作为反向代理将为您提供:

Out of the box, putting nginx in front as a reverse proxy is going to give you:

  • 访问日志
  • 错误日志
  • 轻松终止SSL
  • SPDY支持
  • gzip支持
  • 在几行中为某些路由设置HTTP标头的简便方法
  • 非常快速的静态资产服务(但是,如果您要使用S3/etc等服务,则无关紧要)

Go HTTP服务器非常好,但是 您将需要重新发明一些事情来做这些事情(很好:这并不意味着每个人都能做到).

The Go HTTP server is very good, but you will need to reinvent the wheel to do some of these things (which is fine: it's not meant to be everything to everyone).

我总是发现将nginx放在前面是很容易的,这是它的优势所在,然后让它做"Web服务器"工作.我的Go应用程序执行应用程序的工作,并且仅执行最少的headers/etc.它需要的.不要把nginx放在前面是一件坏"的事情.

I've always found it easier to put nginx in front—which is what it is good at—and let it do the "web server" stuff. My Go application does the application stuff, and only the bare minimum of headers/etc. that it needs to. Don't look at putting nginx in front as a "bad" thing.

这篇关于在用于Go的Web服务器前使用Nginx有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆