Re: silva 2.3, mod_wsgi, and host header

Andrew Altepeter <[email protected]> Wed, 31 Aug 2011 12:56:30 -0500
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <CAEssFdBGtdma8fyoj8=b++1F0e+w9P8SsuQ+5r45ssLs39b0xA@mail.gmail.com>
--===============7659312783264549712==
Content-Type: multipart/alternative; boundary=000e0cd47dec13991e04abd0d943

--000e0cd47dec13991e04abd0d943
Content-Type: text/plain; charset=ISO-8859-1

Hi Sylvain,

Thanks for your prompt response.  From the trac web page you referenced,
adding:
WSGIApplicationGroup %{GLOBAL}
did the trick.

The mod_wsgi directived page,
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIApplicationGroup,
states that using GLOBAL is required if a C extension for python is
using
the "simplified threading API for manipulation of the Python GIL".  I know
zope has some c extensions, so I wonder if that is where the problem lies.

Thanks again for pointing me to a workaround.
Andy

On Wed, Aug 31, 2011 at 2:42 AM, Sylvain Viollon <[email protected]> wrote:

>
> Op 30 aug 2011, om 22:17 heeft Andrew Altepeter het volgende geschreven:
>
> > Greetings,
> >
>
>   Hello,
>
> > We've encountered a very unusual error when running Silva 2.3 in Apache
> (2.0
> > or 2.2) with mod_wsgi.  This error surfaced in production for use with
> our
> > varnish caching server in front of some of our web pages.  This is very
> easy
> > to reproduce:
> >
> > 1) create a new buildout of Silva 2.3, make sure to include the
> mod_wsgi_app
> > part
> > 2) configure your apache server to serve Silva 2.3 with mod_wsgi, the
> > standard configuration from docs.infrae.com/silva/2.3/wsgi.html should
> > suffice.  For the purposes of this test, run the vhost on port 8080.
> > 3) start up apache, load a web page from your browser
> > 4) now in a terminal, access apache using telnet, type the following.
>  We're
> > issuing a standard HTTP/1.1 request, but supplying a different HOST:
> header.
> > aaltepet@bilbo:~/silva/Silva-2.3> telnet localhost 8080
> > Escape character is '^]'.
> > GET / HTTP/1.1
> > HOST: localhost:6080
> >
> > The output you get is similar to (I'm not printing the response body):
> > HTTP/1.1 500 Internal Server Error
> > Date: Tue, 30 Aug 2011 19:47:26 GMT
> > Server: Apache/2.2.15 (Linux/SUSE)
> > Vary: accept-language,accept-charset
> > Accept-Ranges: bytes
> > Connection: close
> > Content-Type: text/html; charset=iso-8859-1
> > Content-Language: en
> > X-Pad: avoid browser bug
> >
> > There is a bizarre zope error recorded in the error log, see this
> pastebin
> > post: http://pastebin.com/3ZMZ8EDB
> >
> > This is reproducible for us on rhel4/apache 2.0/mod_wsgi 3.3 and
> > opensuse11.3/apache 2.2/ mod_wsgi 3.3
> >
> > Issuing multiple requests via telnet, varying the host header, I can see
> > that any INVALID host header raises this error, it does not matter
> whether
> > it is localhost or something.  ONLY VALID hosts, with the correct port,
> are
> > handled properly.  Also, HTTP/1.0 requests raise the same error.
> >
> > Additionally, when running Silva 2.3 under paster, any value for the host
> > header is accepted.
> >
>
>    That's paster buisness to parse and read the HOST header, and build the
> WSGI environment with it. It is possible
>   there is a different between paster authorizes and what mod_wsgi
> authorizes.
>
> > This seems to be a mod_wsgi issue, but given the odd zope error I thought
> > I'd start by reporting it here.
> >
>
>    This errors happens while importing Zope. This happens because it seems
> you defined multiple
>   interpreter with the same name, and they got mixed.
>
>   You have a detail here:
> http://trac.edgewall.org/wiki/TracSubversion#instance-dict-restricted-mode(see the closed issues).
>
>   (It is trac but it the same issue, I am certain. However on how to
> reproduce this error, and how to fix it differently I
>    don't know. Maybe it is a race condition at import, but still I don't
> understand all that going on in embedding Python in Apache).
>
>    Regards,
>
>    Sylvain,
>
> --
> Sylvain Viollon -- Infrae
> t +31 10 243 7051 -- http://infrae.com
> Hoevestraat 10 3033GC Rotterdam -- The Netherlands
>
>
>
>

--000e0cd47dec13991e04abd0d943
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Sylvain,<div><br></div><div>Thanks for your prompt response. =A0From the=
 trac web page you referenced, adding:</div><div>WSGIApplicationGroup %{GLO=
BAL}</div><div>did the trick.</div><div><br></div><div>The mod_wsgi directi=
ved page, =A0<a href=3D"http://code.google.com/p/modwsgi/wiki/Configuration=
Directives#WSGIApplicationGroup">http://code.google.com/p/modwsgi/wiki/Conf=
igurationDirectives#WSGIApplicationGroup</a> , states that using GLOBAL is =
required if a C extension for python is using the &quot;<meta http-equiv=3D=
"content-type" content=3D"text/html; charset=3Dutf-8"><span class=3D"Apple-=
style-span" style=3D"font-family: arial, sans-serif; font-size: 14px; -webk=
it-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">=
simplified threading API for manipulation of the Python GIL&quot;. =A0I kno=
w zope has some c extensions, so I wonder if that is where the problem lies=
.</span></div>
<div><span class=3D"Apple-style-span" style=3D"font-family: arial, sans-ser=
if; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border=
-vertical-spacing: 2px; "><br></span></div><div><span class=3D"Apple-style-=
span" style=3D"font-family: arial, sans-serif; font-size: 14px; -webkit-bor=
der-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Thanks=
 again for pointing me to a workaround.</span></div>
<div><span class=3D"Apple-style-span" style=3D"font-family: arial, sans-ser=
if; font-size: 14px; -webkit-border-horizontal-spacing: 2px; -webkit-border=
-vertical-spacing: 2px; ">Andy</span></div><div><br><div class=3D"gmail_quo=
te">
On Wed, Aug 31, 2011 at 2:42 AM, Sylvain Viollon <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:[email protected]">[email protected]</a>&gt;</span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex;">
<br>
Op 30 aug 2011, om 22:17 heeft Andrew Altepeter het volgende geschreven:<br=
>
<br>
&gt; Greetings,<br>
&gt;<br>
<br>
 =A0 Hello,<br>
<div><div></div><div class=3D"h5"><br>
&gt; We&#39;ve encountered a very unusual error when running Silva 2.3 in A=
pache (2.0<br>
&gt; or 2.2) with mod_wsgi. =A0This error surfaced in production for use wi=
th our<br>
&gt; varnish caching server in front of some of our web pages. =A0This is v=
ery easy<br>
&gt; to reproduce:<br>
&gt;<br>
&gt; 1) create a new buildout of Silva 2.3, make sure to include the mod_ws=
gi_app<br>
&gt; part<br>
&gt; 2) configure your apache server to serve Silva 2.3 with mod_wsgi, the<=
br>
&gt; standard configuration from <a href=3D"http://docs.infrae.com/silva/2.=
3/wsgi.html" target=3D"_blank">docs.infrae.com/silva/2.3/wsgi.html</a> shou=
ld<br>
&gt; suffice. =A0For the purposes of this test, run the vhost on port 8080.=
<br>
&gt; 3) start up apache, load a web page from your browser<br>
&gt; 4) now in a terminal, access apache using telnet, type the following. =
=A0We&#39;re<br>
&gt; issuing a standard HTTP/1.1 request, but supplying a different HOST: h=
eader.<br>
&gt; aaltepet@bilbo:~/silva/Silva-2.3&gt; telnet localhost 8080<br>
&gt; Escape character is &#39;^]&#39;.<br>
&gt; GET / HTTP/1.1<br>
&gt; HOST: localhost:6080<br>
&gt;<br>
&gt; The output you get is similar to (I&#39;m not printing the response bo=
dy):<br>
&gt; HTTP/1.1 500 Internal Server Error<br>
&gt; Date: Tue, 30 Aug 2011 19:47:26 GMT<br>
&gt; Server: Apache/2.2.15 (Linux/SUSE)<br>
&gt; Vary: accept-language,accept-charset<br>
&gt; Accept-Ranges: bytes<br>
&gt; Connection: close<br>
&gt; Content-Type: text/html; charset=3Diso-8859-1<br>
&gt; Content-Language: en<br>
&gt; X-Pad: avoid browser bug<br>
&gt;<br>
&gt; There is a bizarre zope error recorded in the error log, see this past=
ebin<br>
&gt; post: <a href=3D"http://pastebin.com/3ZMZ8EDB" target=3D"_blank">http:=
//pastebin.com/3ZMZ8EDB</a><br>
&gt;<br>
&gt; This is reproducible for us on rhel4/apache 2.0/mod_wsgi 3.3 and<br>
&gt; opensuse11.3/apache 2.2/ mod_wsgi 3.3<br>
&gt;<br>
&gt; Issuing multiple requests via telnet, varying the host header, I can s=
ee<br>
&gt; that any INVALID host header raises this error, it does not matter whe=
ther<br>
&gt; it is localhost or something. =A0ONLY VALID hosts, with the correct po=
rt, are<br>
&gt; handled properly. =A0Also, HTTP/1.0 requests raise the same error.<br>
&gt;<br>
&gt; Additionally, when running Silva 2.3 under paster, any value for the h=
ost<br>
&gt; header is accepted.<br>
&gt;<br>
<br>
</div></div> =A0 That&#39;s paster buisness to parse and read the HOST head=
er, and build the WSGI environment with it. It is possible<br>
 =A0 there is a different between paster authorizes and what mod_wsgi autho=
rizes.<br>
<div class=3D"im"><br>
&gt; This seems to be a mod_wsgi issue, but given the odd zope error I thou=
ght<br>
&gt; I&#39;d start by reporting it here.<br>
&gt;<br>
<br>
</div> =A0 This errors happens while importing Zope. This happens because i=
t seems you defined multiple<br>
 =A0 interpreter with the same name, and they got mixed.<br>
<br>
 =A0 You have a detail here: <a href=3D"http://trac.edgewall.org/wiki/TracS=
ubversion#instance-dict-restricted-mode" target=3D"_blank">http://trac.edge=
wall.org/wiki/TracSubversion#instance-dict-restricted-mode</a> (see the clo=
sed issues).<br>

<br>
 =A0 (It is trac but it the same issue, I am certain. However on how to rep=
roduce this error, and how to fix it differently I<br>
 =A0 =A0don&#39;t know. Maybe it is a race condition at import, but still I=
 don&#39;t understand all that going on in embedding Python in Apache).<br>
<br>
 =A0 =A0Regards,<br>
<br>
 =A0 =A0Sylvain,<br>
<font color=3D"#888888"><br>
--<br>
Sylvain Viollon -- Infrae<br>
t +31 10 243 7051 -- <a href=3D"http://infrae.com" target=3D"_blank">http:/=
/infrae.com</a><br>
Hoevestraat 10 3033GC Rotterdam -- The Netherlands<br>
<br>
<br>
<br>
</font></blockquote></div><br></div>

--000e0cd47dec13991e04abd0d943--

--===============7659312783264549712==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
silva-dev mailing list
silva-dev-IAPFreCvJWM6s/[email protected]
https://lists.infrae.com/mailman/listinfo/silva-dev

--===============7659312783264549712==--