5

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 AddOutputFilterByTypeand no Substituteline in the host conf, the JS file is transferred completely (about 1259k bytes). With just the AddOutputFilterByTypeline 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.

3
  • "but the problem also occurs when I remove the Substitute line" <- I would re-check this statement, clear cache or try with a non-caching browsers like "curl" to make really sure. Dec 30, 2016 at 10:24
  • @ezra-s Good point. See my updates above Dec 30, 2016 at 10:51
  • seems like the js carriage returns are from windows or similar? I would try dos2unix on it and recheck. Dec 30, 2016 at 11:13

2 Answers 2

2

I had the same problem and found the answer here:

https://bz.apache.org/bugzilla/show_bug.cgi?id=56176

mod_substitute uses a max length limit per line. If your (messy) page has a line longer than that, the module ends the reponse abruptly.

From 2.4.11, they added a new parameter to control this line size limit.

http://httpd.apache.org/docs/2.4/mod/mod_substitute.html#substitutemaxlinelength

1

By default mod_substitute has a maximum line length of one megabyte.

In your case you must increase the maximum line length value (for example to 2 megabytes).

SubstituteMaxLineLength 2m

The directive SubstituteMaxLineLength is available since version 2.4.11.

In your example:

<Location />
    AddOutputFilterByType SUBSTITUTE text/html application/javascript
    SubstituteMaxLineLength 2m
    Substitute "s!127.0.0.1:18084!my.real.domain.de!in"
</Location>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .