We recently setup an apache reverse proxy with IIS sitting behind it. All of our apps work fine except for one.

In one app we will prepare and stream a PDF file to the user with the follow example code:

Response.ContentType = "binary/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + downloadName + "; size=" + downloadBytes.Length);
Response.OutputStream.Write(downloadBytes, 0, downloadBytes.Length);

The app will seem to hang and never stream the PDF. The app works fine with no proxy. And also if I take a pdf of the same size and store it on the server's file systems and then download from that directory it works fine. It seems to only have a problem when we try to stream using Response.

I suspected the connection wasn't being kept alive while the PDF generated (it takes about 5 to 7 seconds) but I have adjust the timeout and had no luck.

Here is my apache proxy config.

<VirtualHost *:443>

<Proxy *>

Order deny,allow Allow from all

SSLEngine on
SSLCertificateFile C:/certs/example.crt
SSLCertificateKeyFile c:/certs/example.key
ServerName www.example.com

ProxyVia On
ProxyPass / timeout=360
ProxyPassReverse /
ProxyPreserveHost On
LogLevel debug


So I solved my problem.

There was an internal process in the application that would use self referencing URLs to generate the PDF.

I had proxypreservehost on which was causing the PDF process to timeout because of some bad URLs it was generating.

I disabled proxypreservehost and it works like a charm!

  • +1 for coming back and answering your own question. Good etiquette! – Mark Henderson Aug 28 '09 at 5:22

What about excluding the pdf file using the following '!' directive from mod_proxy manual?

The ! directive is useful in situations where you don't want to reverse-proxy a subdirectory, e.g.

ProxyPass /mirror/foo/i ! ProxyPass /mirror/foo http://backend.example.com

will proxy all requests to /mirror/foo to backend.example.com except requests made to /mirror/foo/i.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy