Is it possible to host more than one site within Gevent's pywsgi server? I have a machine with bottlepy and gevent pywsgi server and am curious how I would go about setting up a second site. The only thing I can think of is using something like nginx as a front end and running each gevent server/site on a different internal port. Is this really the best way to approach this?
Asked
Active
Viewed 299 times
2 Answers
2
Virtual hosting is not part of the WSGI protocol.
If you don't want to use nginx or any other frontend server you can write or use an existing wsgi middleware that would dispatch to several underlying wsgi apps.
Something like this (I have not tested it): http://discorporate.us/jek/projects/wfront/
However, wsgi server are mostly meant to be used as app servers, not frontend servers. I would use nginx, apache, lighttpd or any other well tested frontend server and let it do its job. A few reasons for using frontend servers :
- they check request integrity for security
- they support SSL
- they are usually more robust
- they can act as load balancers to several wsgi process in order to scale

gwik
- 679
- 5
- 9
-
Thanks for the info, I had considered writing my own methods but figured that would never be as robust as something like nginx. – scape Sep 05 '12 at 19:13
0
If you'd like to pay attention to CherryPy (As WSGI server) with Bottle (As Application), I have used for a while, and prove it pretty stable.
The following is an example for multiple virtual hosts.
import cherrypy
from bottle import Bottle
import os
app1 = Bottle()
app2 = Bottle()
@app1.route('/')
def homePage():
return "========= home1 ==============="
@app2.route('/')
def homePage_2():
return "========= home2 ==============="
vhost = cherrypy._cpwsgi.VirtualHost(None,
domains={
'www.domain1.com': app1,
'www.domain2.com': app2,
}
)
cherrypy.tree.graft(vhost)
cherrypy.config.update({
'server.socket_host': '192.168.1.4',
'server.socket_port': 80,
})
cherrypy.engine.start()
cherrypy.engine.block()

Jcyrss
- 1,513
- 3
- 19
- 31