Re: silva 2.3, mod_wsgi, and host header

Sylvain Viollon <[email protected]> Wed, 31 Aug 2011 09:42:34 +0200
Newsgroups gmane.comp.web.zope.silva.devel
Message-ID <[email protected]>
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