AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-599121

Tumbelo's questions

Martin Hope
Tumbelo
Asked: 2020-11-04 01:34:12 +0800 CST

使用 mod_proxy 时如何正确增加 Apache 的超时时间

  • 1

背景:

我有机器对机器的通信系统,客户端不时向Apache服务器发送数据。由于使用移动 2G 进行通信,因此通信速度很慢。Apache 使用 mod_wsgi(用于 Django)。

由于客户端在开始通信时不知道实际数据量,因此客户端和服务器之间使用分块传输编码。因为 mod_wsgi 不支持分块传输编码,所以我使用 mod_proxy,它接收块并将它们作为单个请求传递给 mod_wsgi,并在收到所有数据后添加内容长度信息。

问题:

我将服务器上的 Ubuntu 从 16.04 更新到 18.04,之后客户端和服务器之间的一些通信开始失败。从 Apache 的 access.log 中,我可以看到,该服务器使用“大”数据向客户端响应 408。大意味着在这种情况下数据量需要大约 60 秒的时间进行传输。客户端没有任何变化。

我了解到,对于 Apache 2.4(我在服务器的 Ubuntu 18.04 上拥有)TimeOut 是 60 秒,对于早期的 Apache 版本它是 300 秒。我想这是在“大”数据的情况下与新服务器操作系统通信失败的原因。

边注:

我注意到启用 mod_security 可以解决问题(没有“大”数据的 408),但就在我禁用 mod_security 并重新启动 Apache 时,408 返回图片。security.conf 中没有与超时相关的内容。

问题:

如何正确增加 TimeOut?

到目前为止尝试过:

由于 Apache 真的不是我的核心能力,我一直在尝试将 Timeout 增加到某些地方(也尝试过 KeepAliveTimeout,即使我认为这不是正确的方法):

apache.conf 片段:

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 300

example.com.conf 片段:

ProxyRequests Off
ProxyTimeout 300

<Proxy http://example.com:81>
        Order deny,allow
        Allow from all
</Proxy>

<VirtualHost *:80>
        SetEnv proxy-sendcl 1
        ProxyPass / http://example.com:81/ connectiontimeout=300 timeout=300
        ProxyTimeout 300
        ProxyPassReverse / http://example.com:81/
        ProxyPreserveHost On
        ProxyVia Full

        <Directory proxy:*>
                Order deny,allow
                Allow from all
        </Directory>
</VirtualHost>

Listen 81

<VirtualHost *:81>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName example.com
proxy timeout apache-2.4 http-status-code-408
  • 1 个回答
  • 4730 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve