Gil*_*ili 4 httpd httpd.conf mime-type
By default, httpd contains the following configuration:
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
...
</IfModule>
Run Code Online (Sandbox Code Playgroud)
This file contains a mapping from filename extensions to MIME types. Normally this is what I want, but I'd like to disable mapping for reverse proxies. How can I instruct mime_module to process /* but exclude /proxy/*?
mime_module contains the following line:
application/x-msdownload exe dll com bat msi
Run Code Online (Sandbox Code Playgroud)
The application being proxied accepts PUT /proxy/rest/email@gmail.com and returns 200 OK without setting Content-Type or a response body. According to http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-24#section-3.1.1.5 this is perfectly legal (since there is no response body).
mime_module thinks the URL applies to a .com file and mistakenly applies Content-Type: application/x-msdownload. Since I know that /proxy/rest/ never returns files, I'd like to disable mime_module for that path.
我可以想到三种方法来实现这一目标。
在目录、虚拟主机或 .htaccess 上下文中,您可以使用
RemoveType .com
删除映射。我不确定它是否可以在代理上下文中工作,因为那不是实际目录。但是,如果没有,您可以采取相反的方法,从一般列表中删除 .com,然后专门为那些需要的目录添加它。
但是,在您的情况下,查看mod_mime_magic可能更有用。它的基本作用是,它实际上查看文件的内容以查看它的真正内容,而不是具有扩展名到类型的映射。
缺点是它确实增加了处理量,因此您的性能会受到很小的影响。如果您完全接近极限,则需要先进行一些性能测试/负载测试。
如果该目录或位置中的所有数据始终具有相同的类型,则可ForceType以为整个目录/位置设置一个:
.
<Location /proxy>
ForceType image/gif
</Location>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1858 次 |
| 最近记录: |