Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>

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/*?


Why?

mime_module contains the following line:

application/x-msdownload            exe dll com bat msi

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.

share|improve this question
    
What exactly are you trying to stop mod_mime from doing? It does several different kinds of processing such as setting handlers for file types and setting the Content-type: header if the application that you're proxying is too broke to do it itself. –  DerfK Oct 8 '13 at 21:17
    
@DerfK I've added an explanation. –  Gili Oct 8 '13 at 21:33
add comment

2 Answers

up vote 2 down vote accepted
+50

I can think of three ways to achieve this.

  1. Within a directory, virtualhost or .htaccess context, you can use

    RemoveType .com

    to remove the mapping. I'm not certain whether it will work within a proxy context as that's not an actual directory. But if it doesn't, you could go the opposite route of removing .com from the general list, and then specifically adding it for those directories where it's wanted.

  2. However, in your situation it might be more useful to have a look at mod_mime_magic. What it basically does is that instead of having an extension-to-type mapping, it actually looks at the contents of the file to see what it really is.

    The downside is that it does increase processing, so your performance will take a small hit. If you're at all close to your limits, you'll want to do some performance testing/load testing first.

  3. If all data in that directory or location always have the same type, you can set a ForceType for the entire directory/location:

.

<Location /proxy>
   ForceType image/gif
</Location>
share|improve this answer
    
Is there a way for me to invoke TypesConfig against a specific directory (versus adding types one at a time)? –  Gili Oct 16 '13 at 21:33
    
Not that I can think of immediately. But given your situation, mod_mime_magic might be more useful - I'll amend my answer. –  Jenny D Oct 17 '13 at 6:32
    
I tried ForceType none in the sub-directory. Unfortunately this did not remove mod_mime mapping. –  Gili Oct 17 '13 at 18:30
    
Thanks for your help. I've awarded you the bounty and have posted a separate answer explaining what I did. –  Gili Oct 17 '13 at 18:33
    
I'm glad you found a solution that worked. This is really a bit of an edge case; I've been doing apache sysadminning for about a decade now and never come across this question before. (Which, of course, is what made it fun to research!) –  Jenny D Oct 18 '13 at 6:55
add comment

I ended up doing the following:


httpd.conf:

<Location /proxy>
    Include conf/remove_mime.conf
</Location>

remove_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

Not great, but it's the best I could find.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.