本文介绍了NGINX和Gunicorn并行运行的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亚马逊EC2上的许多Django应用程序部署使用HTTP服务器NGINX和Gunicorn。

A lot of Django app deployments over Amazon's EC2 use HTTP servers NGINX and Gunicorn.

我想知道他们实际做什么,为什么两者并行使用。并行运行它们的目的是什么?

I was wondering what they actually do and why both are used in parallel. What is the purpose of running them both in parallel?

推荐答案

NGINX是 。这是第一个在线。它接受传入的连接并决定他们下一步应该去哪里。它还通常提供静态媒体,如CSS,JS和图像。它也可以做其他的事情,如通过SSL加密,缓存等。

They aren't used in parallel. NGINX is a reverse proxy. It's first in line. It accepts incoming connections and decides where they should go next. It also (usually) serves static media such as CSS, JS and images. It can also do other things such as encryption via SSL, caching etc.

Gunicorn是下一层,是一个 。 NGINX看到传入的连接是针对 www.domain.com ,并且知道(通过配置文件)它应该将该连接传递给Gunicorn。 Gunicorn是一个服务器,基本上是一个:

Gunicorn is the next layer and is an application server. NGINX sees that the incoming connection is for www.domain.com and knows (via configuration files) that it should pass that connection onto Gunicorn. Gunicorn is a WSGI server which is basically a:

Gunicorn的工作是管理和运行Django实例(类似于在开发期间使用 django-admin runserver

Gunicorn's job is to manage and run the Django instance(s) (similar to using django-admin runserver during development)

与此设置的对比是使用Apache与 mod_wsgi 模块。在这种情况下,应用服务器实际上是Apache的一部分,作为模块运行。

The contrast to this setup is to use Apache with the mod_wsgi module. In this situation, the application server is actually a part of Apache, running as a module.

这篇关于NGINX和Gunicorn并行运行的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 21:22