[英]Apache 2.4 compression not working when using alias and reverse proxy
问题:我有一个用于提取静态数据的url子路径的别名目录。 我可以得到这个gzip压缩就好了。 但是,当我将代理添加到其他路径并为我的静态数据添加例外时,压缩会停止。
环境
httpd.conf中的密钥配置
<Directory "${SRVROOT}/static">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# I have used FilterProvider as well an know this just does javascript at the moment
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
SetOutputFilter DEFLATE
<IfModule alias_module>
Alias "/static" "${SRVROOT}/static"
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
</IfModule>
使用此配置和SRVROOT下的“ 静态 ”文件夹,我放置一个文件bundle.js (3M数据)。 在http://localhost/static/bundle.js查询此文件,可以通过gzip压缩下载600K。 都好
现在换了。 应用程序的默认路径需要将代理转发到另一个应用程序,而apache只是提供静态内容。
<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>
extra / proxy-html.conf文件内容
#default proxy stuff above...
ProxyRequests off
ProxyPass / http://localhost:5000/
#ProxyPass /static/ /
ProxyHTMLURLMap http://localhost:5000/ /
<Location />
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /
RequestHeader unset Accept-Encoding
</Location>
<Location /static/ >
ProxyPass !
</Location>
这仍然允许我点击我的静态数据,只是现在没有发生gzip压缩。 我不知道这是否是apache中的错误,或者是否有更好的方法来配置它。
这是我的要求:
似乎RequestHeader取消设置Accept-Encoding正在流入另一个Location定义。 这似乎不应该是预期的行为。 这个问题似乎有两个解决方案。
删除ProxyURLMap的示例
ProxyRequests off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
<Location /static/ >
ProxyPass !
</Location>
#Do not use this anymore
#<Location />
# ProxyPassReverse /
# ProxyHTMLEnable On
# ProxyHTMLURLMap / /
# RequestHeader unset Accept-Encoding
#</Location>
使用INFLATE; DEFLATE的示例
ProxyRequests off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
<Location />
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLURLMap / /
SetOutputFilter INFLATE;DEFLATE
</Location>
<Location /static/ >
ProxyPass !
</Location>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.