【问题标题】:Do i need to use apache or nginx to host a server?我需要使用 apache 或 nginx 来托管服务器吗?
【发布时间】:2013-01-23 17:57:53
【问题描述】:

我需要使用 NginX 还是可以在没有 NginX 的情况下托管它?

我正在开发我的第一个 django 项目,并且可以使用以下命令运行应用程序项目:

./manage.py run_gunicorn -c config/gunicorn

然后我可以查看它:

http://127.0.0.1:8000/resources/

我现在想尝试托管它,以便其他 PC 可以访问它。

【问题讨论】:

  • 你不需要 NginX,大多数人用它来提供静态文件。这是我设置博客时使用的示例senko.net/en/django-nginx-gunicorn
  • @mattsnider 我看过那个博客,它很有用,但据我了解,它仍然使用 NginX 作为反向代理。我需要那个吗?

标签: python django apache nginx gunicorn


【解决方案1】:

Gunicorn 是 wsgi http 服务器。最好在 HTTP 代理服务器后面使用 Gunicorn。我们强烈建议您使用 nginx。

@http://gunicorn.org/#deployment

尽管有许多 HTTP 代理可用,但我们强烈建议您使用 Nginx。如果您选择另一个代理服务器,则需要确保在使用默认 Gunicorn 工作程序时它缓冲慢速客户端。如果没有这种缓冲,Gunicorn 很容易受到拒绝服务攻击。

@http://docs.gunicorn.org/en/latest/deploy.html

【讨论】:

    【解决方案2】:

    您不需要前端代理;您可以将像 gunicorn 这样的独立网络服务器直接投入生产。但是你可能有多种原因want to use a frontend webserver anyway

    【讨论】:

      【解决方案3】:

      当然不是。您可以使用 lighttpd 或任何其他支持 WSGI、SCGI、FastCGI 或 AJP 的 Web 服务器。你可以参考这个python documentationdjango documentation,stackoverflow上的这两个问题:Cleanest & Fastest server setup for DjangoDifferences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?可能也有帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-18
        • 2011-03-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-14
        • 2012-07-02
        • 2012-11-11
        相关资源
        最近更新 更多