apache2反向代理无意中改变了内容

时间:2014-01-29 18:27:43

标签: apache reverse-proxy

我已将Apache2配置为充当IIS中运行的网站的反向代理,以便为该网站卸载SSL和ModSecurity。它似乎对大多数浏览器都很有用,直到我尝试从iPad访问该网站,此时显然它正在重写页面一点点,导致页面加载不正确。

如果我更改用户代理以匹配iPad的用户代理,我可以在其他浏览器中重新创建该问题。

页面源代码的前几行应如下所示:

<!DOCTYPE html>
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" /><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" /><meta name="format-detection" content="telephone=no" /><title>

        Login - Intuition by Vertex
</title>
    <link href="/VertexIntuition/Content/images/favicon.png" rel="icon" type="image/png" />

    <script src="/VertexIntuition/bundles/jquery?v=UgyEMAYOuSB9Bb6HcOEVHpd6fIIp54yF086SRNVcdIY1"></script>
<script src="/VertexIntuition/bundles/tablet?v=2kDCvhCBNKBgX0qN9fTU9DAHVqMl3xRFihmIqyYo6hY1"></script>
<link href="/VertexIntuition/Content/style/tabletbundle?v=ItHS3VZO8NwiILS32jviRjVSaLWeZuF0S17HnIT_2Y01" rel="stylesheet"/>


    <!-- Framework CSS -->
    <!--[if lt IE 8]>

    <link rel="stylesheet" href="/VertexIntuition/Content/style/tablet/blueprint/ie.css" type="text/css" media="screen, projection" />
    <![endif]-->

    <!-- Page specific styles -->

    </head>
<body>

当通过反向代理访问页面时,源的相同块被重写为:

<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="format-detection" content="telephone=no"><title>

        Login - Intuition by Vertex
</title><link href="/VertexIntuition/Content/images/favicon.png" rel="icon" type="image/png"><script src="/VertexIntuition/bundles/jquery?v=UgyEMAYOuSB9Bb6HcOEVHpd6fIIp54yF086SRNVcdIY1"></script><script src="/VertexIntuition/bundles/tablet?v=2kDCvhCBNKBgX0qN9fTU9DAHVqMl3xRFihmIqyYo6hY1"></script><link href="/VertexIntuition/Content/style/tabletbundle?v=ItHS3VZO8NwiILS32jviRjVSaLWeZuF0S17HnIT_2Y01" rel="stylesheet"><!-- Framework CSS --><!--[if lt IE 8]>

    <link rel="stylesheet" href="/VertexIntuition/Content/style/tablet/blueprint/ie.css" type="text/css" media="screen, projection" />
    <![endif]--><!-- Page specific styles --></head><body>

并且页面的布局最终格式不正确(不仅仅是这一部分文本被更改,我只是将其用作更改的示例。)

网站的配置如下:

<VirtualHost *:443>
  ServerAdmin webmaster@localhost
  ErrorLog /var/log/apache2/reverseproxy-ssl_error.log
  LogLevel info
  CustomLog /var/log/apache2/access-ssl.log combined

  ProxyRequests off

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  ProxyPreserveHost On
  ProxyHTMLInterp on

  ProxyPass / http://internal.site.local/
  ProxyPassReverse / http://internal.site.local/

  SetOutputFilter proxy-html
  ProxyHTMLURLMap http://internal.site.local /

  RequestHeader    unset  Accept-Encoding

  SSLEngine on
  SSLProxyEngine On

  SSLCertificateFile    /etc/ssl/certs/server.crt
  SSLCertificateKeyFile /etc/ssl/private/server.key
  SSLCertificateChainFile /etc/ssl/certs/intermediate.crt
</VirtualHost>

我现在已完全禁用ModSecurity以解决问题,但问题仍然存在,所以不应该这样。

我正在使用的URL看起来像这样: https://mysite.example.com/VertexIntuition/SystemUser/Login 而且,它似乎适用于大多数其他浏览器

如果我跑

wget --user-agent="Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B405 Safari/531.21.10" http://internal.site.local/VertexIntuition/SystemUser/Login"
从作为反向代理运行的服务器

,我得到的页面显示正确。

1 个答案:

答案 0 :(得分:1)

显然实际上没有问题,只是一些奇怪的缓存问题和一个ModSecurity规则的组合。我的配置很好。

触发规则集,导致问题是modsecurity_crs_21_protocol_anomalies.conf 这导致页面的呈现不正确。关闭ModSecurity后问题仍然存在,因为我的浏览器没有正确清除缓存。