【问题标题】:Getting net::ERR_EMPTY_RESPONSE on local apache setup在本地 apache 设置上获取 net::ERR_EMPTY_RESPONSE
【发布时间】:2020-05-07 04:09:41
【问题描述】:

我正在本地开发一个进行 API 调用的网络应用程序。一些 API 调用突然停止工作,而另一些继续工作。如果我在浏览器中直接访问 api 端点,第一次它总是返回:

This page isn’t working
samplesite.com didn’t send any data.
ERR_EMPTY_RESPONSE

请求头是:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: PHPSESSID=xxx; _ga=GAxxx; _gid=GAxxx; __stripe_mid=xxx; __stripe_sid=xxx
Host: samplesite.com
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36

我的 apache 日志中出现错误:

[Mon Jan 20 22:10:18.133644 2020] [core:notice] [pid 4702] AH00052: child pid 6191 exit signal Segmentation fault (11)
[Mon Jan 20 22:14:02.343396 2020] [core:notice] [pid 4702] AH00052: child pid 6241 exit signal Segmentation fault (11)
[Mon Jan 20 22:14:02.343886 2020] [core:notice] [pid 4702] AH00052: child pid 6240 exit signal Segmentation fault (11)
[Mon Jan 20 22:14:07.349923 2020] [core:notice] [pid 4702] AH00052: child pid 6212 exit signal Segmentation fault (11)

试图获取有关该过程的详细信息不会返回任何结果:

alan:~$ ps -p 6212
PID TTY           TIME CMD

如果我刷新页面,第二次(以及所有其他时间)它将返回正确的数据(为了测试,我让 api 端点简单地输出“hello world”)。

为了解决我试过:

  • 重启apache
  • 清除浏览器缓存
  • 以隐身模式发出请求
  • 在 Firefox、Safari 和 Chrome 中

我刚刚更新到 Catalina,但不认为这是相关的,因为我相信我之前遇到过这个错误并且它自行消失了。

有什么建议吗?谢谢。

【问题讨论】:

    标签: apache httpd.conf


    【解决方案1】:

    在 Firefox 中读取错误提供了更多线索。火狐的错误说:

    Secure Connection Failed: The page you are trying to view cannot be shown because the authenticity of the received data could not be verified
    

    所以由于某种原因存在 SSL 问题。我在本地创建了一个用于测试的自签名 SSL 证书(支持通配符子域);它还没有过期,所以我不确定为什么会突然出现问题。

    解决方案:不要在本地使用 https 并更新我的 .htaccess 文件以仅在实时站点 (mysite.com) 而不是开发站点 (mysite.test) 上强制 https:

    RewriteEngine On
    
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} mysite.com$
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    我还卸载了 Apache 和 OpenSSL,但我不认为这是解决问题的原因。

    【讨论】:

    • 也许尝试将RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 更改为RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    • 感谢@chi-c-j-rajeeva-lochana 但这并没有改变任何东西
    • RewriteCond %{HTTPS} !=on 解决了我的问题,谢谢!
    【解决方案2】:

    试试这个:

    RewriteCond %{HTTPS} !on
    RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ ([^\ ]+)
    RewriteRule ^ https://%{HTTP_HOST}%2 [L,R=301]
    

    您仍然希望启用 https 重定向,除此之外,如果您没有完整的 https 支持,您的网站排名将受到影响。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-17
      • 2019-11-11
      • 2019-09-01
      • 2011-02-08
      • 1970-01-01
      • 2011-09-12
      • 1970-01-01
      相关资源
      最近更新 更多