本文介绍了Go(golang)webservices的Webserver:是否使用NGINX?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



你会推荐使用NGINX作为网络服务器,或者它足够使用标准的http服务器的Go?

解决方案

它取决于。



将nginx放在前面作为反向代理会给你:
$ b


  • 访问日志


  • 简易SSL终止

  • SPDY支持

  • gzip支持

  • 轻松设置特定路由的HTTP头几行

  • 非常快的静态资产服务(如果你服务于S3 / etc,尽管如此,是不相关的)



Go HTTP服务器非常好,但是您需要重新创建轮子做一些这些事情(这很好:它并不意味着是每个人的一切)。



我总是发现把nginx放在前面比较容易-whic h是它擅长的 - 并让它执行web服务器的东西。我的Go应用程序执行应用程序的任务,并且只有最低限度的头文件/ etc。它需要。不要把nginx放在前面作为坏的东西。


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

Would you recommend to use NGINX as a webserver or it is good enough to use the standard http server of Go?

解决方案

It depends.

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

  • Access logs
  • Error logs
  • Easy SSL termination
  • SPDY support
  • gzip support
  • Easy ways to set HTTP headers for certain routes in a couple of lines
  • Very fast static asset serving (if you're serving off S3/etc. though, this isn't that relevant)

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).

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(golang)webservices的Webserver:是否使用NGINX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 18:03