Apache reverse proxy removes headers from webdav server

apache-2.2reverse-proxywebdav

I have been using Davenport+Tomcat through an Apache AJP reverse proxy for several years and it has been a great help in my institution. I would like to migrate to SAMBADAV maintaining the same configuration for my users who access davenport server through a reverse proxy.

What I am currently using in my apache configuration for Davenport reverse proxy are these directives:

    ProxyPass /webfolders ajp://davenport.my.domain:8009/webfolders flushpackets=on
    ProxyPassReverse /webfolders ajp://davenport.my.domain:8009/webfolders

So I have tried to do the same with a working configuration on http:// sambadav.my.domain/webfolders. As I have not found any documentation, I have tried with:

    ProxyPass /webfolders http://sambadav.my.domain/webfolders
    ProxyPassReverse /webfolders http://sambadav.my.domain/webfolders

And that works for web browsing and some webdav clients (Sardine/0.0, Windows) but does not work for some other webdav clients (gvfs/1.20.3 and others) which work correctly with both direct connection to sambadav server and current proxyed connection to davenport server.

Analizing traffic I see that -after authorization- when SAMBADAV replies to OPTION request a 200 OK to the Apache reverse proxy server, it sends these headers:

HTTP/1.1 200 OK
Date: Wed, 21 Sep 2016 09:31:13 GMT
Server: Apache/2.4.10 (Debian)
X-Sabre-Version: 3.0.9
Allow: OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, LOCK, UNLOCK
DAV: 1, 3, extended-mkcol, 2
MS-Author-Via: DAV
Accept-Ranges: bytes
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

While Apache reverse proxy server sends different headers back to the client:

HTTP/1.1 200 OK
Date: Wed, 21 Sep 2016 09:31:13 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Cache-Control: max-age=0, no-cache
Content-Length: 20
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

And that is when client supposes that "the server does not support WebDAV".

How can I make Apache reverse proxy not to filter these headers?

I have also tried including the next location directive with no success.

    <Location /webfolders/>
      <Limit OPTIONS PROPFIND GET REPORT MKACTIVITY PROPPATCH PUT CHECKOUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE>
        Order Deny,Allow
        Allow from all
        Satisfy Any
      </Limit>
    </Location>

These are the webdav clients I've tried with reverse proxy, some of them not working with SAMBADAV (and Apache reverse proxy), but working with Davenport (and Apache AJP reverse proxy)

| Operating System | Client                                           | Works? |
--------------------------------------------------------------------------------
|     Linux        | gvfs/1.20.3                                      | No     |
|     Linux        | davfs2/1.4.7 neon/0.30.0                         | No     |
|    MacOS X       | WebDAVFS/3.0.0 (03008000) Darwin/15.6.0 (x86_64) | No     |
|    MacOS X       | WebDAVLib/1.3                                    |  idem  |
|   Windows 10     | Microsoft-WebDAV-MiniRedir/10.0.10586            | Yes    |
|    Android       | Sardine/0.0                                      | Yes    |

Best Answer

Writing the question I have noticed the header Content-Encoding: gzip.

This was the problem: I had the pagespeed_module enabled. Once disabled the proxy works. So I've modified the location and now everything works!!!

    ProxyPass /WEBFOLDERS http://sambadav.iib.uam.es/webfolders

    <Location /webfolders/>
      ProxyPassReverse /webfolders/
      <Limit OPTIONS PROPFIND GET REPORT MKACTIVITY PROPPATCH PUT CHECKOUT MKCOL MOVE COPY DELETE LOCK UNLOCK MERGE>
        Order Deny,Allow
        Allow from all
        Satisfy Any
      </Limit>
#     <IfModule pagespeed_module>
         ModPagespeed off
#     </IfModule>

    </Location>