logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Excel and Word docs forced to download as zip
Author
wesma33



Joined: 17 Dec 2018
Posts: 6
Location: US, Charleston

PostPosted: Tue 25 Jun '19 17:03    Post subject: Excel and Word docs forced to download as zip Reply with quote

I am proxying to an application server. When I login and try to download an excel file or word doc it gives me an option to download the file as a zip not as the original file extension. PDF works fine. I saw a solution on the below but it does not work on apache 2.4. I am on RHEL 7.6 as well.

https://serverfault.com/questions/19060/why-are-docx-xlsx-pptx-downloading-from-webserver-as-zip-files
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Wed 26 Jun '19 9:33    Post subject: Reply with quote

Hello,

which mime-type is sent by webserver to your browser?
Within Chrome you can check with F12-tool, click on "Network" and open the mentioned URL (where you webserver delivers the docx/xlsx-files). Now you should see the mime-type that is send by the webserver.
Is it something from the following list
application/zip, application/x-zip-compressed, multipart/x-zip
or from this list
application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Have you already tried the "AddType"-approach from the serverfault.com-link you have mentioned?
Checked on Apache2.4 for Windows - there is a "/conf/mime.types"-file containing lines (among others) for xlsx and docx. So I guess that this way should work on Apache2.4, too.
Back to top
wesma33



Joined: 17 Dec 2018
Posts: 6
Location: US, Charleston

PostPosted: Wed 26 Jun '19 22:24    Post subject: Reply with quote

I am not able to verify which one. Once I go to network and click the file i wish to download nothing is updated.

I did go back to a basic install and now it is no longer a zip file.

The file is now trying to be downloaded as filename.do
Any document has .do as the extension now.

Yes I added the types in mime.types still no change.
Back to top
mraddi



Joined: 27 Jun 2016
Posts: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Thu 27 Jun '19 7:28    Post subject: Reply with quote

Hello,
oh, sorry - missed the information that your apache is "only" used as reverse proxy. In this case the hints for configuring apache are useless as the application-server is (or at least should be) setting the mime-type within the HTTP-response-header.

If you are requesting something like http://server.tld/path/filename.do the browser contacts the apache which sends the request to the application-server. The application-server should create the data for the response (in this case a docx/xlsx-file) and sends it back (hopefully with correct HTTP-headers containing the filename and mime-type) to apache which forwards it to the requesting browser.
With PHP one would set the HTTP-headers for mime-type and filename using these lines (source: https://www.php.net/manual/de/function.header.php):
Code:
// we will send a pdf-file
header('Content-Type: application/pdf');
// which should be named downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
...

So I guess these information are not send/not send correctly from the application server. This has to be verified by you (with Chrome's F12-tools, Firefox's WebDeveloperTools, or maybe with basic wget/curl/telnet Cool which can display the http-response-headers). If traffic is unencrypted you also can use tcpdump/Wireshark to dump the traffic and analyze afterwards which http-headers are within the response from application-server back to apache.

A modification on the application-server changed the way the file is treated by the browser --> another hint, that application(-server) has to be configured correctly and not apache is creating the wrong http-header-data.

Greetings
Matthias
Back to top


Reply to topic   Topic: Excel and Word docs forced to download as zip View previous topic :: View next topic
Post new topic   Forum Index -> Apache