Hello!
I'm trying to run different flask apps under one lighttpd like so:
server/app1 server/app2
I'm at the point that going to their respective urls i get the right pages.
The problem is getting url_for to work. If I use
werkzeug.contrib.fixers.LighttpdCGIRootFix
instead of server/appx/<url_for generated path> I get server/<url_for
generated path>.
Without fix I get server/appx/appx.fcgi/<url_for generated path> and this
one does not work
as I have rewrite-once rules in place.
in fastcgi.conf I have:
$HTTP["url"] =~ "^/app1" {
server.document-root = server_root + "/apps/app1"
fastcgi.server = (
"/app1.fcgi" => ((
"socket" => socket_dir + "/app1-fcgi.socket",
"check-local" => "disable",
"bin-path" => server_root + "/app1/app1.fcgi"
)),
)
}
$HTTP["url"] =~ "^/app2" {
server.document-root = server_root + "/apps/app2"
fastcgi.server = (
"/app2.fcgi" => ((
"socket" => socket_dir + "/app2-fcgi.socket",
"check-local" => "disable",
"bin-path" => server_root + "/apps/app2.fcgi"
)),
)
}
url.rewrite-once = (
"^/app1/(.*)$" => "/app1/app1.fcgi/$1"
"^/app2/(.*)$" => "/app2/app2.fcgi/$1"
)
It is possible that I have botched up fastcgi.server configuration and it
is just a fluke.
One venue would be to create multiple lighttpd daemons on different ports
and then use one daemon
like a load balancer?
--
Andres Rand
Le 08/11/2011 15:24, Andres Rand a écrit : > Hello! > > I'm trying to run different flask apps under one lighttpd like so: > server/app1 server/app2 > I'm at the point that going to their respective urls i get the right pages. > > The problem is getting url_for to work. If I use > werkzeug.contrib.fixers.LighttpdCGIRootFix > instead of server/appx/<url_for generated path> I get server/<url_for > generated path>. > Without fix I get server/appx/appx.fcgi/<url_for generated path> and > this one does not work > as I have rewrite-once rules in place. > > in fastcgi.conf I have: > > $HTTP["url"] =~ "^/app1" { > server.document-root = server_root + "/apps/app1" > fastcgi.server = ( > "/app1.fcgi" => (( > "socket" => socket_dir + "/app1-fcgi.socket", > "check-local" => "disable", > "bin-path" => server_root + "/app1/app1.fcgi" > )), > ) > } Hi, You should not use LighttpdCGIRootFix since your apps are not at the root of their domain name. How about a config like this? No .fcgi in the URL prefix. (but keep it in bin-path) fastcgi.server = ( "/app1" => (( ... )), "/app2" => (( ... )), ) Note that both app is in its own FastCGI server and process. If you want to have them both in the same process, use a single fastcgi.server line in Lighttpd and this in Python: http://flask.pocoo.org/docs/patterns/appdispatch/#dispatch-by-path Regards, -- Simon Sapin
Hi! I asssumed werkzeug fix would behave differently. Now when I look at docs and my own situation I feel stupid. fastcgi.server = ( "/app1" => (( ... )), "/app2" => (( ... )), ) is exactly what I was trying to achieve. I was thrown off by lack of documentation for this situation. All I could find was django page describing $HTTP["host"] scheme and fastcgi.conf comment suggesting $HTTP["url"] for rails app. Big kudos for Simon! -- Andres Rand 2011/11/9 Simon Sapin <simon.sapin@exyr.org> > > Le 08/11/2011 15:24, Andres Rand a écrit : > > Hello! > > > > I'm trying to run different flask apps under one lighttpd like so: > > server/app1 server/app2 > > I'm at the point that going to their respective urls i get the right pages. > > > > The problem is getting url_for to work. If I use > > werkzeug.contrib.fixers.LighttpdCGIRootFix > > instead of server/appx/<url_for generated path> I get server/<url_for > > generated path>. > > Without fix I get server/appx/appx.fcgi/<url_for generated path> and > > this one does not work > > as I have rewrite-once rules in place. > > > > in fastcgi.conf I have: > > > > $HTTP["url"] =~ "^/app1" { > > server.document-root = server_root + "/apps/app1" > > fastcgi.server = ( > > "/app1.fcgi" => (( > > "socket" => socket_dir + "/app1-fcgi.socket", > > "check-local" => "disable", > > "bin-path" => server_root + "/app1/app1.fcgi" > > )), > > ) > > } > > Hi, > > You should not use LighttpdCGIRootFix since your apps are not at the > root of their domain name. > > How about a config like this? No .fcgi in the URL prefix. (but keep it > in bin-path) > > fastcgi.server = ( > "/app1" => (( ... )), > "/app2" => (( ... )), > ) > > Note that both app is in its own FastCGI server and process. If you want > to have them both in the same process, use a single fastcgi.server line > in Lighttpd and this in Python: > http://flask.pocoo.org/docs/patterns/appdispatch/#dispatch-by-path > > Regards, > -- > Simon Sapin