默认情况下,httpd包含以下配置:
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
...
</IfModule>
此文件包含从文件扩展名到 MIME 类型的映射。通常这就是我想要的,但我想禁用反向代理的映射。我如何指示 mime_module 处理/*
但排除/proxy/*
?
为什么?
mime_module 包含以下行:
application/x-msdownload exe dll com bat msi
被代理的应用程序接受并返回,不设置或响应主体。根据PUT /proxy/rest/[email protected]
200 OK
Content-Type
https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p2-semantics-24#section-3.1.1.5这是完全合法的(因为没有响应主体)。
mime_module
认为 URL 适用于某个.com
文件,但错误地应用了Content-Type: application/x-msdownload
。由于我知道/proxy/rest/
永远不会返回文件,因此我想禁用mime_module
该路径。
答案1
我能想到三种方法来实现这一点。
在目录、虚拟主机或 .htaccess 上下文中,您可以使用
RemoveType .com
删除映射。我不确定它是否能在代理上下文中工作,因为那不是实际的目录。但如果不行,你可以采取相反的路线,从一般列表中删除 .com,然后专门为需要它的目录添加它。
然而,对于你的情况来说,看看mod_mime_magic它基本上所做的是,它不进行扩展名到类型的映射,而是实际查看文件的内容以了解它到底是什么。
缺点是它确实会增加处理量,因此您的性能会受到轻微影响。如果您已经接近极限,则需要先进行一些性能测试/负载测试。
如果该目录或位置中的所有数据始终具有相同的类型,则可
ForceType
以为整个目录/位置设置:
。
<Location /proxy>
ForceType image/gif
</Location>
答案2
我最终做了以下事情:
httpd.conf:
<Location /proxy>
Include conf/remove_mime.conf
</Location>
删除mime.conf:
# Removes configuration set by TypesConfig mime.types
RemoveType ez
RemoveType aw
RemoveType atom
RemoveType atomcat
RemoveType atomsvc
RemoveType ccxml
RemoveType cu
RemoveType davmount
RemoveType dssc
RemoveType xdssc
RemoveType ecma
RemoveType emma
RemoveType epub
RemoveType pfr
RemoveType stk
RemoveType ipfix
RemoveType jar
RemoveType ser
RemoveType class
RemoveType js
RemoveType json
RemoveType lostxml
RemoveType hqx
RemoveType cpt
RemoveType mrc
RemoveType ma nb mb
RemoveType mathml
RemoveType mbox
RemoveType mscml
RemoveType mp4s
RemoveType doc dot
RemoveType mxf
RemoveType bin dms lha lrf lzh so iso dmg dist distz pkg bpk dump elc deploy
RemoveType oda
RemoveType opf
RemoveType ogx
RemoveType onetoc onetoc2 onetmp onepkg
RemoveType xer
RemoveType pdf
RemoveType pgp
RemoveType asc sig
RemoveType prf
RemoveType p10
RemoveType p7m p7c
RemoveType p7s
RemoveType cer
RemoveType crl
RemoveType pkipath
RemoveType pki
RemoveType pls
RemoveType ai eps ps
RemoveType cww
RemoveType rdf
RemoveType rif
RemoveType rnc
RemoveType rl
RemoveType rld
RemoveType rs
RemoveType rsd
RemoveType rss
RemoveType rtf
RemoveType sbml
RemoveType scq
RemoveType scs
RemoveType spq
RemoveType spp
RemoveType sdp
RemoveType setpay
RemoveType setreg
RemoveType shf
RemoveType smi smil
RemoveType rq
RemoveType srx
RemoveType gram
RemoveType grxml
RemoveType ssml
RemoveType plb
RemoveType psb
RemoveType pvb
RemoveType tcap
RemoveType pwn
RemoveType aso
RemoveType imp
RemoveType acu
RemoveType atc acutc
RemoveType air
RemoveType xdp
RemoveType xfdf
RemoveType azf
RemoveType azs
RemoveType azw
RemoveType acc
RemoveType ami
RemoveType apk
RemoveType cii
RemoveType fti
RemoveType atx
RemoveType mpkg
RemoveType m3u8
RemoveType swi
RemoveType aep
RemoveType mpm
RemoveType bmi
RemoveType rep
RemoveType cdxml
RemoveType mmd
RemoveType cdy
RemoveType cla
RemoveType rp9
RemoveType c4g c4d c4f c4p c4u
RemoveType csp
RemoveType cdbcmsg
RemoveType cmc
RemoveType clkx
RemoveType clkk
RemoveType clkp
RemoveType clkt
RemoveType clkw
RemoveType wbs
RemoveType pml
RemoveType ppd
RemoveType car
RemoveType pcurl
RemoveType rdz
RemoveType fe_launch
RemoveType dna
RemoveType mlp
RemoveType dpg
RemoveType dfac
RemoveType geo
RemoveType mag
RemoveType nml
RemoveType esf
RemoveType msf
RemoveType qam
RemoveType slt
RemoveType ssf
RemoveType es3 et3
RemoveType ez2
RemoveType ez3
RemoveType fdf
RemoveType mseed
RemoveType seed dataless
RemoveType gph
RemoveType ftc
RemoveType fm frame maker book
RemoveType fnc
RemoveType ltf
RemoveType fsc
RemoveType oas
RemoveType oa2
RemoveType oa3
RemoveType fg5
RemoveType bh2
RemoveType ddd
RemoveType xdw
RemoveType xbd
RemoveType fzs
RemoveType txd
RemoveType ggb
RemoveType ggt
RemoveType gex gre
RemoveType gxt
RemoveType g2w
RemoveType g3w
RemoveType gmx
RemoveType kml
RemoveType kmz
RemoveType gqf gqs
RemoveType gac
RemoveType ghf
RemoveType gim
RemoveType grv
RemoveType gtm
RemoveType tpl
RemoveType vcg
RemoveType zmm
RemoveType hbci
RemoveType les
RemoveType hpgl
RemoveType hpid
RemoveType hps
RemoveType jlt
RemoveType pcl
RemoveType pclxl
RemoveType sfd-hdstx
RemoveType x3d
RemoveType mpy
RemoveType afp listafp list3820
RemoveType irm
RemoveType sc
RemoveType icc icm
RemoveType igl
RemoveType ivp
RemoveType ivu
RemoveType xpw xpx
RemoveType qbo
RemoveType qfx
RemoveType rcprofile
RemoveType irp
RemoveType xpr
RemoveType jam
RemoveType rms
RemoveType jisp
RemoveType joda
RemoveType ktz ktr
RemoveType karbon
RemoveType chrt
RemoveType kfo
RemoveType flw
RemoveType kon
RemoveType kpr kpt
RemoveType ksp
RemoveType kwd kwt
RemoveType htke
RemoveType kia
RemoveType kne knp
RemoveType skp skd skt skm
RemoveType sse
RemoveType lbd
RemoveType lbe
RemoveType 123
RemoveType apr
RemoveType pre
RemoveType nsf
RemoveType org
RemoveType scm
RemoveType lwp
RemoveType portpkg
RemoveType mcd
RemoveType mc1
RemoveType cdkey
RemoveType mwf
RemoveType mfm
RemoveType flo
RemoveType igx
RemoveType mif
RemoveType daf
RemoveType dis
RemoveType mbk
RemoveType mqy
RemoveType msl
RemoveType plc
RemoveType txf
RemoveType mpn
RemoveType mpc
RemoveType xul
RemoveType cil
RemoveType cab
RemoveType xls xlm xla xlc xlt xlw
RemoveType xlam
RemoveType xlsb
RemoveType xlsm
RemoveType xltm
RemoveType eot
RemoveType chm
RemoveType ims
RemoveType lrm
RemoveType cat
RemoveType stl
RemoveType ppt pps pot
RemoveType ppam
RemoveType pptm
RemoveType sldm
RemoveType ppsm
RemoveType potm
RemoveType mpp mpt
RemoveType docm
RemoveType dotm
RemoveType wps wks wcm wdb
RemoveType wpl
RemoveType xps
RemoveType mseq
RemoveType mus
RemoveType msty
RemoveType nlu
RemoveType nnd
RemoveType nns
RemoveType nnw
RemoveType ngdat
RemoveType n-gage
RemoveType rpst
RemoveType rpss
RemoveType edm
RemoveType edx
RemoveType ext
RemoveType odc
RemoveType otc
RemoveType odb
RemoveType odf
RemoveType odft
RemoveType odg
RemoveType otg
RemoveType odi
RemoveType oti
RemoveType odp
RemoveType otp
RemoveType ods
RemoveType ots
RemoveType odt
RemoveType otm
RemoveType ott
RemoveType oth
RemoveType xo
RemoveType dd2
RemoveType oxt
RemoveType pptx
RemoveType sldx
RemoveType ppsx
RemoveType potx
RemoveType xlsx
RemoveType xltx
RemoveType docx
RemoveType dotx
RemoveType dp
RemoveType pdb pqa oprc
RemoveType paw
RemoveType str
RemoveType ei6
RemoveType efif
RemoveType wg
RemoveType plf
RemoveType pbd
RemoveType box
RemoveType mgz
RemoveType qps
RemoveType ptid
RemoveType qxd qxt qwd qwt qxl qxb
RemoveType bed
RemoveType mxl
RemoveType musicxml
RemoveType cod
RemoveType rm
RemoveType link66
RemoveType st
RemoveType see
RemoveType sema
RemoveType semd
RemoveType semf
RemoveType ifm
RemoveType itp
RemoveType iif
RemoveType ipk
RemoveType twd twds
RemoveType mmf
RemoveType teacher
RemoveType sdkm sdkd
RemoveType dxp
RemoveType sfs
RemoveType sdc
RemoveType sda
RemoveType sdd
RemoveType smf
RemoveType sdw
RemoveType vor
RemoveType sgl
RemoveType sxc
RemoveType stc
RemoveType sxd
RemoveType std
RemoveType sxi
RemoveType sti
RemoveType sxm
RemoveType sxw
RemoveType sxg
RemoveType stw
RemoveType sus susp
RemoveType svd
RemoveType sis sisx
RemoveType xsm
RemoveType bdm
RemoveType xdm
RemoveType tao
RemoveType tmo
RemoveType tpt
RemoveType mxs
RemoveType tra
RemoveType ufd ufdl
RemoveType utz
RemoveType umj
RemoveType unityweb
RemoveType uoml
RemoveType vcx
RemoveType vsd vst vss vsw
RemoveType vis
RemoveType vsf
RemoveType wbxml
RemoveType wmlc
RemoveType wmlsc
RemoveType wtb
RemoveType nbp
RemoveType wpd
RemoveType wqd
RemoveType stf
RemoveType xar
RemoveType xfdl
RemoveType hvd
RemoveType hvs
RemoveType hvp
RemoveType osf
RemoveType osfpvg
RemoveType saf
RemoveType spf
RemoveType cmp
RemoveType zir zirz
RemoveType zaz
RemoveType vxml
RemoveType hlp
RemoveType wsdl
RemoveType wspolicy
RemoveType abw
RemoveType ace
RemoveType aab x32 u32 vox
RemoveType aam
RemoveType aas
RemoveType bcpio
RemoveType torrent
RemoveType bz
RemoveType bz2 boz
RemoveType vcd
RemoveType chat
RemoveType pgn
RemoveType cpio
RemoveType csh
RemoveType deb udeb
RemoveType dir dcr dxr cst cct cxt w3d fgd swa
RemoveType wad
RemoveType ncx
RemoveType dtb
RemoveType res
RemoveType dvi
RemoveType bdf
RemoveType gsf
RemoveType psf
RemoveType otf
RemoveType pcf
RemoveType snf
RemoveType ttf ttc
RemoveType pfa pfb pfm afm
RemoveType spl
RemoveType gnumeric
RemoveType gtar
RemoveType hdf
RemoveType jnlp
RemoveType latex
RemoveType prc mobi
RemoveType application
RemoveType wmd
RemoveType wmz
RemoveType xbap
RemoveType mdb
RemoveType obd
RemoveType crd
RemoveType clp
RemoveType exe dll com bat msi
RemoveType mvb m13 m14
RemoveType wmf
RemoveType mny
RemoveType pub
RemoveType scd
RemoveType trm
RemoveType wri
RemoveType nc cdf
RemoveType p12 pfx
RemoveType p7b spc
RemoveType p7r
RemoveType rar
RemoveType sh
RemoveType shar
RemoveType swf
RemoveType xap
RemoveType sit
RemoveType sitx
RemoveType sv4cpio
RemoveType sv4crc
RemoveType tar
RemoveType tcl
RemoveType tex
RemoveType tfm
RemoveType texinfo texi
RemoveType ustar
RemoveType src
RemoveType der crt
RemoveType fig
RemoveType xpi
RemoveType xenc
RemoveType xhtml xht
RemoveType xml xsl
RemoveType dtd
RemoveType xop
RemoveType xslt
RemoveType xspf
RemoveType mxml xhvml xvml xvm
RemoveType zip
RemoveType adp
RemoveType au snd
RemoveType mid midi kar rmi
RemoveType mp4a
RemoveType mpga mp2 mp2a mp3 m2a m3a
RemoveType oga ogg spx
RemoveType eol
RemoveType dra
RemoveType dts
RemoveType dtshd
RemoveType lvp
RemoveType pya
RemoveType ecelp4800
RemoveType ecelp7470
RemoveType ecelp9600
RemoveType aac
RemoveType aif aiff aifc
RemoveType m3u
RemoveType wax
RemoveType wma
RemoveType ram ra
RemoveType rmp
RemoveType wav
RemoveType cdx
RemoveType cif
RemoveType cmdf
RemoveType cml
RemoveType csml
RemoveType xyz
RemoveType bmp
RemoveType cgm
RemoveType g3
RemoveType gif
RemoveType ief
RemoveType jpeg jpg jpe
RemoveType png
RemoveType btif
RemoveType svg svgz
RemoveType tiff tif
RemoveType psd
RemoveType djvu djv
RemoveType dwg
RemoveType dxf
RemoveType fbs
RemoveType fpx
RemoveType fst
RemoveType mmr
RemoveType rlc
RemoveType mdi
RemoveType npx
RemoveType wbmp
RemoveType xif
RemoveType ras
RemoveType cmx
RemoveType fh fhc fh4 fh5 fh7
RemoveType ico
RemoveType pcx
RemoveType pic pct
RemoveType pnm
RemoveType pbm
RemoveType pgm
RemoveType ppm
RemoveType rgb
RemoveType xbm
RemoveType xpm
RemoveType xwd
RemoveType eml mime
RemoveType igs iges
RemoveType msh mesh silo
RemoveType dwf
RemoveType gdl
RemoveType gtw
RemoveType mts
RemoveType vtu
RemoveType wrl vrml
RemoveType ics ifb
RemoveType css
RemoveType csv
RemoveType html htm
RemoveType txt text conf def list log in
RemoveType dsc
RemoveType rtx
RemoveType sgml sgm
RemoveType tsv
RemoveType t tr roff man me ms
RemoveType uri uris urls
RemoveType curl
RemoveType dcurl
RemoveType scurl
RemoveType mcurl
RemoveType fly
RemoveType flx
RemoveType gv
RemoveType 3dml
RemoveType spot
RemoveType jad
RemoveType wml
RemoveType wmls
RemoveType s asm
RemoveType c cc cxx cpp h hh dic
RemoveType f for f77 f90
RemoveType p pas
RemoveType java
RemoveType etx
RemoveType uu
RemoveType vcs
RemoveType vcf
RemoveType 3gp
RemoveType 3g2
RemoveType h261
RemoveType h263
RemoveType h264
RemoveType jpgv
RemoveType jpm jpgm
RemoveType mj2 mjp2
RemoveType mp4 mp4v mpg4
RemoveType mpeg mpg mpe m1v m2v
RemoveType ogv
RemoveType qt mov
RemoveType fvt
RemoveType mxu m4u
RemoveType pyv
RemoveType viv
RemoveType f4v
RemoveType fli
RemoveType flv
RemoveType m4v
RemoveType asf asx
RemoveType wm
RemoveType wmv
RemoveType wmx
RemoveType wvx
RemoveType avi
RemoveType movie
RemoveType ice
不算太好,但这是我能找到的最好的。