代理服务器从上游服务器收到无效响应

代理服务器从上游服务器收到无效响应

我在 apache 后面有 tomcat 服务器。我正在使用 mod_ssl 和 tomcat 的反向代理。所有都在默认端口上运行。

完整错误如下。ack 代理错误

代理服务器从上游服务器收到无效响应。代理服务器无法处理请求 POST /pages/doeditpage.action。

原因:从远程服务器读取时出错

如果我清理浏览器缓存,错误就会消失,但尝试几次后又会再次出现。我在 Windows 平台上的 Chrome/Firefox/IE 上进行了同样的测试。想知道它在基于 Linux 的 Chrome/Firefox 上是否能完美运行。

我在 Google 上搜索了很多,在 Stack Overflow 上找到的答案很少,但我找不到答案。这是服务器端的问题吗?因为 Windows 上不可能同时有这么多浏览器出错。

答案1

回答我自己的问题。基本上,如果 Apache 到 Tomcat 的连接器存在一些问题,则可能会发生此类问题。

在我的例子中,我将超时值减少到了 5 毫秒,我认为这对于任何基于互联网的应用程序来说都太少了。此外,我在 8443 处打开了一个可以与 Apache 通信的新连接器。

就代理和反向代理而言,您可以使用默认的非安全端口 8080,并将安全和代理端口指定为 443(apache 安全端口)。

默认端口 8080 连接器中的 secure="true" scheme="https" proxyPort=443 解决了这个问题。我知道对于任何具有 Java/Web 背景的人来说,这可能是非常基本的东西,但对于像我这样对 JAVA 应用服务器一无所知的人来说,弄清楚这一点真的很痛苦。

答案2

在您的 apache 配置中尝试以下内容。我添加了注释,因为它实际上随 debian 默认配置一起提供。并解释为什么使用这些选项:

    #   SSL Protocol Adjustments:
    #   The safe and default but still SSL/TLS standard compliant shutdown
    #   approach is that mod_ssl sends the close notify alert but doesn't wait for
    #   the close notify alert from client. When you need a different shutdown
    #   approach you can use one of the following variables:
    #   o ssl-unclean-shutdown:
    #     This forces an unclean shutdown when the connection is closed, i.e. no
    #     SSL close notify alert is send or allowed to received.  This violates
    #     the SSL/TLS standard but is needed for some brain-dead browsers. Use
    #     this when you receive I/O errors because of the standard approach where
    #     mod_ssl sends the close notify alert.
    #   o ssl-accurate-shutdown:
    #     This forces an accurate shutdown when the connection is closed, i.e. a
    #     SSL close notify alert is send and mod_ssl waits for the close notify
    #     alert of the client. This is 100% SSL/TLS standard compliant, but in
    #     practice often causes hanging connections with brain-dead browsers. Use
    #     this only for browsers where you know that their SSL implementation
    #     works correctly.
    #   Notice: Most problems of broken clients are also related to the HTTP
    #   keep-alive facility, so you usually additionally want to disable
    #   keep-alive for those clients, too. Use variable "nokeepalive" for this.
    #   Similarly, one has to force some clients to use HTTP/1.0 to workaround
    #   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
    #   "force-response-1.0" for this.
    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    BrowserMatch "MSIE [17-6]" ssl-unclean-shutdown

基本上关闭 IE 6 及以下版本的保持活动,并取消 ssl-unclean-shutdown,直到当前(和未来)版本的 IE。如果这对你仍然不起作用,请尝试以下操作

    BrowserMatch "MSIE [17-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    #BrowserMatch "MSIE [17-6]" ssl-unclean-shutdown

相关内容