Thread: [Cppcms-users] lighttp + fastcgi configuration problem
Brought to you by:
artyom-beilis
From: Alexey U. <um...@gm...> - 2012-01-16 08:57:12
|
Hello! After running my test app behind the web back-end I've encountered a problem with URL dispatching. I have a virtual host on my machine "app.net" and appropriate record has been putted to /etc/hosts: "app.net 127.0.0.1". I'm running my app externally. My lighttp configuration related to subject is as follows: $HTTP["host"] == "app.net" { server.document-root = "/opt/sites/app/" alias.url += ("/scripts" => "/opt/sites/app/scripts" ) } # here I expect all address strings which contain "app.net" are delivered to my app fastcgi.server = ( "/" => (( "socket" => "/tmp/app-fcgi-socket", "max-procs" => 1, "check-local" => "disable" )) ) My CppCMS config: { "service" : { "api" : "fastcgi", "socket" : "/tmp/app-fcgi-socket" } } I manage URLs in following way: MyApp::MyApp(cppcms::service& srv) : cppcms::application(srv) { dispatcher().assign("", &MyApp::main, this); dispatcher().assign("/home", &MyApp::main, this); dispatcher().assign("/page1", &MyApp::page1, this); dispatcher().assign("/page2", &MyApp::page2, this); } void MyApp::main() { content::Home home; home.text = "Welcome home!"; render("Home", home); } void MyApp::page1() { content::Page1 page; page.text = "Page 1"; render("Page", page); } void MyApp::page2() { content::Page2 page; page.text = "Page"; render("Page2", page2); } I expected the following behavior: http://app.net -> "Welcome home!" http://app.net/page1 -> "Page 1" http://app.net/page2 -> "Page 2" but I'm getting the following: http://app.net -> "Welcome home!" http://app.net/page1 -> "Welcome home!" http://app.net/page2 -> "Welcome home!" And I've noticed that http://app.net -> "Welcome home!" http://app.net/asd/page1 -> "Page 1" http://app.net/asd/page2 -> "Page 2" (I can use any string in place of "asd" above and it's OK) Seems like there are lighttp configuration problem but I don't know how to cope with it. Any ideas about how to achieve what I expect? Thank you! |
From: Artyom B. <art...@ya...> - 2012-01-16 11:48:13
|
You need URL Rewriting: Read this: http://art-blog.no-ip.info/wikipp/en/page/run_application_web_server_root Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.sf.net/ CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ >________________________________ > From: Alexey Umnov <um...@gm...> >To: cpp...@li... >Sent: Monday, January 16, 2012 10:56 AM >Subject: [Cppcms-users] lighttp + fastcgi configuration problem > > >Hello! > > >After running my test app behind the web back-end I've encountered a problem with URL dispatching. >I have a virtual host on my machine "app.net" and appropriate record has been putted to /etc/hosts: "app.net 127.0.0.1". >I'm running my app externally. My lighttp configuration related to subject is as follows: > > >$HTTP["host"] == "app.net" { >server.document-root = "/opt/sites/app/" >alias.url += ("/scripts"=>"/opt/sites/app/scripts") >} > > ># here I expect all address strings which contain "app.net" are delivered to my app >fastcgi.server = ( "/" => (( >"socket" => "/tmp/app-fcgi-socket", >"max-procs" => 1, >"check-local" => "disable" >)) >) > > >My CppCMS config: >{ >"service" : { >"api" : "fastcgi", >"socket" : "/tmp/app-fcgi-socket" >} >} > > >I manage URLs in following way: >MyApp::MyApp(cppcms::service& srv) : >cppcms::application(srv) >{ >dispatcher().assign("", &MyApp::main, this); >dispatcher().assign("/home", &MyApp::main, this); >dispatcher().assign("/page1", &MyApp::page1, this); >dispatcher().assign("/page2", &MyApp::page2, this); >} > > >void MyApp::main() { >content::Home home; >home.text = "Welcome home!"; >render("Home", home); >} > > >void MyApp::page1() { >content::Page1 page; >page.text = "Page 1"; >render("Page", page); >} > > >void MyApp::page2() { >content::Page2 page; >page.text = "Page"; >render("Page2", page2); >} > > >I expected the following behavior: >http://app.net -> "Welcome home!" >http://app.net/page1 -> "Page 1" >http://app.net/page2 -> "Page 2" > > >but I'm getting the following: >http://app.net -> "Welcome home!" >http://app.net/page1 -> "Welcome home!" >http://app.net/page2 -> "Welcome home!" > > >And I've noticed that >http://app.net -> "Welcome home!" >http://app.net/asd/page1 -> "Page 1" >http://app.net/asd/page2 -> "Page 2" > > >(I can use any string in place of "asd" above and it's OK) > > >Seems like there are lighttp configuration problem but I don't know how to cope with it. > > >Any ideas about how to achieve what I expect? >Thank you! >------------------------------------------------------------------------------ >RSA(R) Conference 2012 >Mar 27 - Feb 2 >Save $400 by Jan. 27 >Register now! >http://p.sf.net/sfu/rsa-sfdev2dev2 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
From: Alexey U. <um...@gm...> - 2012-01-17 10:59:47
|
Thanks for the link. I should have read it before... Eventually it helped :) But such a kind of configuration is quite hard (at least to me - I'm not versed in web back-ends) to make it work off the cuff. So I think fit to put some of my configurations here - perhaps it would be of help to someone. I know my lighttpd.conf isn't well written for production, but it works for me while I'm in research. piece of my lighttpd.conf related to this particular application: $HTTP["host"] == "app.net" { server.document-root = "/opt/sites/app", alias.url = ( "/scripts" => "/opt/sites/app/scripts/", ) url.rewrite-once = ( "^(/scripts/.*)" => "$1", "^/(.*)" => "/app/$1" ) fastcgi.server = ( "/app" => (( "socket" => "/tmp/app-fcgi-socket", "max-procs" => 1, "check-local" => "disable", )) ) } CppCMS config: { "service" : { "api" : "fastcgi", "socket" : "/tmp/app-fcgi-socket" } } Good luck! On Mon, Jan 16, 2012 at 3:48 PM, Artyom Beilis <art...@ya...> wrote: > > You need URL Rewriting: > > Read this: > http://art-blog.no-ip.info/wikipp/en/page/run_application_web_server_root > > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.sf.net/ > CppDB - C++ SQL Connectivity: http://cppcms.sf.net/sql/cppdb/ > > ------------------------------ > *From:* Alexey Umnov <um...@gm...> > *To:* cpp...@li... > *Sent:* Monday, January 16, 2012 10:56 AM > *Subject:* [Cppcms-users] lighttp + fastcgi configuration problem > > Hello! > > After running my test app behind the web back-end I've encountered a > problem with URL dispatching. > I have a virtual host on my machine "app.net" and appropriate record has > been putted to /etc/hosts: "app.net 127.0.0.1". > I'm running my app externally. My lighttp configuration related to subject > is as follows: > > $HTTP["host"] == "app.net" { > server.document-root = "/opt/sites/app/" > alias.url += ("/scripts" => "/opt/sites/app/scripts" ) > } > > # here I expect all address strings which contain "app.net" are delivered > to my app > fastcgi.server = ( "/" => (( > "socket" => "/tmp/app-fcgi-socket", > "max-procs" => 1, > "check-local" => "disable" > )) > ) > > My CppCMS config: > { > "service" : { > "api" : "fastcgi", > "socket" : "/tmp/app-fcgi-socket" > } > } > > I manage URLs in following way: > MyApp::MyApp(cppcms::service& srv) : > cppcms::application(srv) > { > dispatcher().assign("", &MyApp::main, this); > dispatcher().assign("/home", &MyApp::main, this); > dispatcher().assign("/page1", &MyApp::page1, this); > dispatcher().assign("/page2", &MyApp::page2, this); > } > > void MyApp::main() { > content::Home home; > home.text = "Welcome home!"; > render("Home", home); > } > > void MyApp::page1() { > content::Page1 page; > page.text = "Page 1"; > render("Page", page); > } > > void MyApp::page2() { > content::Page2 page; > page.text = "Page"; > render("Page2", page2); > } > > I expected the following behavior: > http://app.net -> "Welcome home!" > http://app.net/page1 -> "Page 1" > http://app.net/page2 -> "Page 2" > > but I'm getting the following: > http://app.net -> "Welcome home!" > http://app.net/page1 -> "Welcome home!" > http://app.net/page2 -> "Welcome home!" > > And I've noticed that > http://app.net -> "Welcome home!" > http://app.net/asd/page1 -> "Page 1" > http://app.net/asd/page2 -> "Page 2" > > (I can use any string in place of "asd" above and it's OK) > > Seems like there are lighttp configuration problem but I don't know how to > cope with it. > > Any ideas about how to achieve what I expect? > Thank you! > > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Mar 27 - Feb 2 > Save $400 by Jan. 27 > Register now! > http://p.sf.net/sfu/rsa-sfdev2dev2 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > RSA(R) Conference 2012 > Mar 27 - Feb 2 > Save $400 by Jan. 27 > Register now! > http://p.sf.net/sfu/rsa-sfdev2dev2 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |