3

I have a couple of compressed zip file with static HTML content (e.g. a directory tree of documentation with several static html pages that link to each other, images, css, etc.) For instance, the javadoc zip file serves as an equivalent example for my purpose.

My question is, if there's an apache module that would allow apache to "mount" a zip file as a virtual directory, whose contents are those of the zip file. The operating system in which I'm hosting apache is Mac OS X Snow Leopard.

Ernesto
  • 3,837
  • 6
  • 35
  • 56
  • Why wouldn't you just unzip the file? – Frank Farmer Dec 07 '11 at 18:24
  • I have the javadoc zip file, that Netbeans uses as is, compressed, to let you browse it with an internal web server that Netbeans starts when the Netbeans application is running. But when I don't have Netbeans open I can't use this. I was hoping to achieve the same thing with apache. I could decompress it, of course, but I figured that this should be possible, not to mention that is very efficient to have a huge zip of static html pages, which would otherwise occupy much more disk space without providing more efficiency. – Ernesto Apr 05 '12 at 18:17

3 Answers3

4

There is a zip filesystem for FUSE, which is supported on OS X via the MacFUSE project. This will let you mount a zip file via the mount command, thus allowing Apache -- or any other application -- to access its contents as a normal directory.

I don't have my Mac handy at the moment so I can't actually test it out.

larsks
  • 277,717
  • 41
  • 399
  • 399
2

I'm not aware of any existing Apache modules to do this, but you could implement it without touching Apache internals by adding a CGI script which handles access to ZIP archives:

Action zip-archive /cgi-bin/ziphandler.cgi
AddHandler zip-archive .zip

This will make ziphandler.cgi get called for all accesses to .zip files, or (more importantly!) to files in "directories" under .zip files. From there, it should be pretty straightforward.

  • If I only had the time to implement such a thing, I would be thrilled, since it would be a new experience. But I have never developed an Apache module and being this not so far-fetched, I thought there would be some implementation already available. Unfortunately I haven't found any yet. – Ernesto Apr 05 '12 at 18:18
0

Using proxy_http you can forward requests to Jetty which will serve any ZIP file.

Download Jetty Runner from here: http://mvnrepository.com/artifact/org.eclipse.jetty/jetty-runner

You can run it using e.g. java -jar jetty-runner-9.3.0.M2.jar --port 8082 myZIPFile.zip. Now set up Apache to forward requests to localhost:8082. You can do that for even only one subdirectory.

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196