On Tue, Feb 8, 2011 at 11:21 AM, Oetzi <[email protected]> wrote:
> Could you give me some guidance on how to set up a cherry py server?
> My host has a cherry py app but I don't know anything about it.
I use bottle framework right now, so I'm not 100% sure but it should
work something like this:
from cherrypy import wsgiserver
server = wsgiserver.CherryPyWSGIServer(('127.0.0.1', 8080), app)
server.start()
This runs the cherrypy instance accessible from localhost only at port
8080. Now you have to set up nginx as a reverse proxy so that nginx
handles all communication with the outside world. Here's how I do it:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log /path/to/log/file.log;
}
location ~ /static/(.*) {
alias /path/to/your/app/static/files/$1;
access_log off;
expires 300d;
}
}
With this setup, nginx would serve up static files, and the cherrpy
would serve your WSGI app. Cherrypy is threaded so you'll get multiple
threads started once you start the app. It therefore consumes quite a
bit of memory compared to lightweight servers like bjoern[1] (which I
recommend).
At any rate, this setup is much easier to do than mod_wsgi, and if you
use servers like bjoern, it's also much faster.
For the static server, I also recommend lighty over nginx, but I never
had time to learn lighty configuration so I use nginx. At any rate,
for most apps, you won't have to worry about performance differences.
Most apps never see that many users.
[1] https://github.com/jonashaag/bjoern
--
Branko Vukelic
[email protected]
http://www.brankovukelic.com/
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.