I'm trying to set up a Shopware site using Docker behind a Apache2 reverse proxy. Since the Shopware software for some reason puts its backend host "http://127.0.0.1:18084" into the JavaScript it sends to the browser, I tried to use mod_substitute to replace it with the external host name:
ProxyPass / http://127.0.0.1:18084/
ProxyPassReverse / http://127.0.0.1:18084/
<Location />
AddOutputFilterByType SUBSTITUTE text/html application/javascript
Substitute "s!127.0.0.1:18084!my.real.domain.de!in"
</Location>
This does work, i.e. the host name is replaced. However, some JavaScript files are sent using chunked encoding, and this causes problems in the browser (output from the JS console):
GET http://my.real.domain.de/engine/Library/ExtJs/ext-all.js?201611281529
net::ERR_INCOMPLETE_CHUNKED_ENCODING
My first thought was that the substitution was messing with the chunk lengths, but the problem also occurs when I remove the Substitute
line. Just having a AddOutputFilterByType
line for content type application/javascript
causes the problem.
The reverse proxy Apache is version 2.4.7, the backend apache is 2.4.18.
Am I doing something wrong, or is this an apache problem? (There were some issues with apache reverse proxy messing up the last, empty, chunk in 2.2, but I think this should be fixed by now)
Update:
ezra_s made the point that I should make sure that the browser cache does not play into this. I checked using curl
:
With no AddOutputFilterByType
and no Substitute
line in the host conf, the JS file is transferred completely (about 1259k bytes). With just the AddOutputFilterByType
line enabled I get the folowing output:
here:~ tos$ curl http://my.real.domain.de/engine/Library/ExtJs/ext-all.js?201611281529
/*
This file is part of Ext JS 4.1
Copyright (c) 2011-2012 Sencha Inc
Contact: http://www.sencha.com/contact
GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as
published by the Free Software Foundation and appearing in the file LICENSE included in the
packaging of this file.
Please review the following information to ensure the GNU General Public License version 3.0
requirements will be met: http://www.gnu.org/copyleft/gpl.html.
If you are unsure which license is appropriate for your use, please contact the sales department
at http://www.sencha.com/contact.
Build date: 2012-07-04 21:11:01 (65ff594cd80b9bad45df640c22cc0adb52c95a7b)
*/
curl: (18) transfer closed with outstanding read data remaining
here:~ tos$
This shows a similar behavior, but shows that not just the end-chunk is missing, but everything but the first chunk.
I checked this with tcpdump. It also shows only one chunk arriving.
Update 2:
This seems to be a problem with mod_substitute. In the error log of my reverse proxy I find the following line:
[Fri Dec 30 11:44:03.934066 2016] [substitute:error] [pid 2725] [client xxx.xxx.xxx.xxx:56492] AH01328: Line too long, URI /engine/Library/ExtJs/ext-all.js
It seems that the javascript is packed into one long line, which is too long for mod_substitute
, which fails even before a substitution is defined.
I think I'll re-open this as a new question, if I can't find a solution to this.