Skip to content

errors on loading .css and .js files through revproxy #92

Closed
vdzk opened this Issue Feb 20, 2012 · 12 comments

3 participants

@vdzk
vdzk commented Feb 20, 2012

When trying to load .css and .js files through revproxy, there is no response. Following errors apear in log:

=ERROR REPORT==== 17-Feb-2012::21:05:55 ===
Yaws process died: {badarg,
[{erlang,list_to_integer,
["/!jQueryv1.7jquery.com|jquery.org/license/",
16],
[]},
{yaws_revproxy,ploop,3,
[{file,"src/yaws_revproxy.erl"},{line,266}]},
{yaws_server,aloop,4,
[{file,"src/yaws_server.erl"},{line,1142}]},
{yaws_server,acceptor0,2,
[{file,"src/yaws_server.erl"},{line,1010}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}
=ERROR REPORT==== 17-Feb-2012::21:05:55 ===
Yaws process died: {badarg,
[{erlang,list_to_integer,["/*",16],[]},
{yaws_revproxy,ploop,3,
[{file,"src/yaws_revproxy.erl"},{line,266}]},
{yaws_server,aloop,4,
[{file,"src/yaws_server.erl"},{line,1142}]},
{yaws_server,acceptor0,2,
[{file,"src/yaws_server.erl"},{line,1010}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,227}]}]}

@vinoski
Collaborator
vinoski commented Feb 21, 2012

We're working on some rev proxy changes that will hopefully address this.

@capflam
Collaborator
capflam commented Feb 24, 2012

The reverse proxy has been refactored. Maybe it will fix your problems.

@vdzk
vdzk commented Feb 27, 2012

After the update there are no errors recorded in log but the issue still remains. Now, either css, js files do not load with 500 Internal Server Error or they load extremely slow. To see this, rev proxy should not be on localhost.

@capflam
Collaborator
capflam commented Feb 27, 2012

It's strange, I can't reproduce this behaviour. Here is my vhost configuration:

  <server myrkr>
        port       = 8001
        listen     = 0.0.0.0
        docroot    = /home/christopher/Test/yaws/var/yaws/www
        deflate    = true
        auth_log   = true
        access_log = true
        revproxy   = / http://www.erlang.org
  </server>

Can you provide more information on your server configuration ?
To have more information about what the revproxy do, you can build yaws with debug by typing:

make debug

and executing yaws in interactive mode.

@capflam
Collaborator
capflam commented Feb 27, 2012

Can you also provide the output of the following command when you try to get a JS/CSS file ?

  wget -d -O/dev/null http://....css
@vdzk
vdzk commented Feb 27, 2012

Configuration:

logdir = /home/andrey/git/doublerevproxy/logs
 <server www.alpha4.dev>
 port = 8001
 listen = 0.0.0.0
 docroot = /home/andrey/git/doublerevproxy/www
 revproxy = /revproxy2 http://www.alpha4.dev:8002
 </server>

 <server www.alpha4.dev>
 port = 8002
 listen = 0.0.0.0
 docroot = /home/andrey/git/doublerevproxy/www
 </server>

 <server www.alpha4.dev>
 port = 8080
 listen = 0.0.0.0
 docroot = /home/andrey/git/doublerevproxy/www
 revproxy = /revproxy1 http://www.alpha4.dev:8001
 </server>

Load http://www.alpha4.dev:8080/revproxy1/revproxy2/jquery.js in Firefox. Open 'Net' tab of FireBug. If you press F5 a few times, you can see that most of the requests take 25-30 seconds.

If wget is run during slow requests like these, it shows lag:

~$ wget -d -O/dev/null http://www.alpha4.dev:8080/revproxy1/revproxy2/jquery.js
Setting --output-document (outputdocument) to /dev/null
DEBUG output created by Wget 1.12 on linux-gnu.

--2012-02-27 14:29:49--  http://www.alpha4.dev:8080/revproxy1/revproxy2/jquery.js
Resolving www.alpha4.dev... 127.0.1.1
Caching www.alpha4.dev => 127.0.1.1
Connecting to www.alpha4.dev|127.0.1.1|:8080... connected.
Created socket 4.
Releasing 0x0000000001158b40 (new refcount 1).

---request begin---
GET /revproxy1/revproxy2/jquery.js HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: www.alpha4.dev:8080
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 200 OK
Connection: keep-alive
Server: Yaws 1.92
Date: Mon, 27 Feb 2012 12:30:13 GMT
Last-Modified: Tue, 21 Feb 2012 11:32:38 GMT
Etag: "3Cq2CYACLOP"
Content-Length: 248235
Content-Type: application/x-javascript

---response end---
200 OK
Registered socket 4 for persistent reuse.
Length: 248235 (242K) [application/x-javascript]
Saving to: “/dev/null”

100%[======================================>] 248,235     --.-K/s   in 0.001s  

2012-02-27 14:30:13 (399 MB/s) - “/dev/null” saved [248235/248235]
@vdzk
vdzk commented Feb 27, 2012

In a more complicated configuration which uses arg_rewrite, wget shows:


$ wget -d -O/dev/null http://www.alpha4.dev:8080/stc/default/css/style.css
Setting --output-document (outputdocument) to /dev/null
DEBUG output created by Wget 1.12 on linux-gnu.

--2012-02-27 13:50:38--  http://www.alpha4.dev:8080/stc/default/css/style.css
Resolving www.alpha4.dev... 127.0.1.1
Caching www.alpha4.dev => 127.0.1.1
Connecting to www.alpha4.dev|127.0.1.1|:8080... connected.
Created socket 4.
Releasing 0x0000000001a35470 (new refcount 1).

---request begin---
GET /stc/default/css/style.css HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */*
Host: www.alpha4.dev:8080
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 500 Internal Server Error
Connection: close
Server: Yaws 1.92
Date: Mon, 27 Feb 2012 11:50:38 GMT
Content-Length: 47
Content-Type: text/html

---response end---
500 Internal Server Error
Closed fd 4
2012-02-27 13:50:38 ERROR 500: Internal Server Error.
@capflam
Collaborator
capflam commented Feb 27, 2012

Thanks for these information. I've tried to reproduce this problem but unfortunately I couldn't. I used a similar configuration of yours: https://gist.github.com/1927164.
I don't know if it could help, but you can test it: http://www.capflam.org:8080/revproxy1/revproxy2/stil.css

Just in case, have you check that it's not a DNS problem ?

About your arg_rewrite module, which kind of url rewriting do you use ?

@capflam capflam was assigned Feb 27, 2012
@capflam
Collaborator
capflam commented Feb 28, 2012

Hi,

mdaguete has reported in the issue #89 the same problem that you observed about request latencies. If you've set proxy_keepalive to true, my last commit (b1b4e2b) may fix this problem.

@vdzk
vdzk commented Mar 5, 2012

Looks like we've moved closer to the root of the problem. It turns out that the file extension doesn't matter. Any file above a certain size triggers 500 Internal Server Error. Here is a test: http://www.sendspace.com/file/vha4gw .

Error occures when rev_proxy is used together with yaws appmod which returns tuple {page, <path-file>} where <path-file> is not very small. More details in the test README.

@capflam
Collaborator
capflam commented Mar 6, 2012

Thanks for your report. It was very useful.

I found and fix the bug. There was nothing to do with the reverse proxy but with reentrant requests. The response headers were not correctly set, in particular the Content-Length header. Note that this fix also addresses the issue #91.

Can you confirm that it fixes your problem ?

@vdzk
vdzk commented Mar 7, 2012

Thank you for the patch. It does fix this issue. I'll check #91 shortly.

@vdzk vdzk closed this Mar 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.