Thread: [Cppcms-users] Some remarks
Brought to you by:
artyom-beilis
From: Markus R. <us...@ma...> - 2009-10-27 14:19:58
|
Hello list! I am currently working with cppcms for an opensource project. I will announce it (with code) when there is something useful. For now I have some questions and remarks. First I have to thank for the great work already done! Lots of basic technical stuff (manager, application_factory, worker_thread,...) and helpers (cppcms_run) are there which makes working with fcgi much easier and faster. While I was first sceptical about the static templates, I like them very much now too. It is nice that you get a compile error when there is something wrong with the template and it is certainly the solution achieving best performance. 1.) How do use cpp_cms for production server? Can someone explain me how to use cppcms_run for a production release or is it not suitable for that? I want that the user (not root!) running it has access to the document root, but of course no write access to the fcgi program (which should not be inside the document root). I am a bit confused why the document root is an absolut path, while the fcgi process must be relative: /usr/local/bin/cppcms_run: line 474: ./MY_ABS_PATH/hello.fcgi: File not found (so ./ is prefixed there) 2.) How can I run the site at the root of the server? When I use -s /hello, I can access the site at http://markusbyte:8080/hello/. How can I completely avoid the /hello/ to access the site at http://markusbyte:8080/. I hope it can be done without rewrite rules. It would be perfect if there is a webserver independend way? 3.) Using filters in other classes than base_view. The filters like escape can be only used in base_view classes (or classes inheriting from it) and I don't see any reason why. In addition to that there are not const, but they don't modify the object (they just return a string). I would suggest to make them as functions or static methods. 4.) Wrong mime type for failure pages. For 500 internal server errors, 404 document not found and so on the Content-Type is text/plain even though a html page is shown[0]. 5.) Interface to set_header. In cppcms::application set_header takes a pointer to HTTPHeader. When I look into cppcms::worker_thread::set_header I see that a auto_ptr is taking ownership of this pointer. Maybe the documentation points out that too, but it would be much clearer if the the auto_ptr is used in the interface. Having that, it would be easy to see that you can pass a fresh allocated object without having to worry what will happen. So it should read: void set_header(std::auto_ptr<cgicc::HTTPHeader> h) { worker.set_header(h); } This list is now also available as usenet group gmane.comp.lib.cppcms.users. thank you Markus Raab [0] $ telnet markusbyte 8080 Trying 192.168.0.3... Connected to markusbyte.markus-raab.org. Escape character is '^]'. GET / HTTP 1.1 HTTP/1.1 404 Not found Date: Tue, 27 Oct 2009 13:46:24 GMT Server: Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 X-Powered-By: cppcms/0.0.4 Content-Length: 248 Connection: close Content-Type: text/plain <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>404 - Not Found</title> </head> <body> <h1>404 - Not Found</h1> </body> </html> Connection closed by foreign host. |
From: Artyom <art...@ya...> - 2009-10-27 20:54:31
|
Hello > Can someone explain me how to use cppcms_run for a production release or is it > not suitable for that? Defenatly not. cppcms_run is just tool for debugging and testing the framework agains different web servers. You should run CppCMS process just like and other FastCGI process and you should refer to the web server documentation. In general there are two ways of running 1. Run web server and start cppcms service externally -- that what cppcms run does. 2. Make web server manage CppCMS applications (Not supported by Nginx) For example. This is configuration of production CppCMS wiki service for lighttpd: server.modules += ( "mod_fastcgi" ) fastcgi.server = ( "/wikipp" => (( "bin-path" => "/some/path/to/wikipp -c /some/path/to/config-wikipp.txt", "socket" => "/tmp/wikipp.socket", "max-procs" => 1, "check-local" => "disable" )) ) Notes: a) max-procs == 1 -- make sure that only one process is started. CppCMS controls its processes on its own. b) check-local = disable -- do to try to find a real executable or script. c) Also config-wikipp.txt DOES NOT define specific socket in order to use stdin as socket. See: http://art-blog.no-ip.info/wikipp/en/page/ref_config#server-api d) When web server starts application it runs under web server permissions, if you want to limit it even more you may use various mods like chroot etc. Generally just run cppcms_run and take a look on created configuration and start working with them. CppCMS is just a simple FastCGI or SCGI service. ------------------- > I am a bit confused why the document root is an absolut path, while the fcgi > process must be relative: > /usr/local/bin/cppcms_run: line 474: ./MY_ABS_PATH/hello.fcgi: File not found > (so ./ is prefixed there) It is just because I'm too lazy to write full path. So cppcms_run assumes that the script is placed in current working directory and it names script -- the base path according to program name by default. cppcms_run mostly used for testing and debugging. > 2.) How can I run the site at the root of the server? > > When I use -s /hello, I can access the site at http://markusbyte:8080/hello/. > How can I completely avoid the /hello/ to access the site at > http://markusbyte:8080/. > > I hope it can be done without rewrite rules. It would be perfect if there is a > webserver independend way? Generally it is **bad** idea. And I explain why. Web server does much more then providing fast-cgi service it also serves files. If hello is related to / then if you want to get a file "/hello.css" you need to know how to serve it VIA your program, and beleve me YOU DO NOT want to do this because serving files has LOTs of security issues that should be handled correctly. Generally you may specify as script "/", but some web servers have problem with that. > 3.) Using filters in other classes than base_view. > > The filters like escape can be only used in base_view classes (or classes > inheriting from it) and I don't see any reason why. In addition to that there > are not const, but they don't modify the object (they just return a string). > They are not const but some filter may be non-const. Just think that you may to access DB from filter if cache is not avalible (not that it is correct way to do this) > I would suggest to make them as functions or static methods. > --------- In CppCMS 1.x.x they are static methods. There is one more important quite technical point why these functions are members. Lest assume you have some filter class foo : public cppcms::base_view{ string bar_filter(string somethings); }; When you compile the template to shared object it does not know what foo::foo_bar filter is and it is resolved only when it is "dlopened" This is defenatly not a problem for ELF platform but it is a huge problem for DLL platform. DLLs may have no unresolved symbols! So this problem is simply workarounded by making bar_filter virtual, thus DLL should only know the class layout and not need to know the resolution of specific symbols. So if you want to create custom filter you need to provide them somehow via callback methods -- this means they should be somehow members of your views known in compilation time. boost::function can be used as well (when it is member of class). > 4.) Wrong mime type for failure pages. > > For 500 internal server errors, 404 document not found and so on the > Content-Type is text/plain even though a html page is shown[0]. Ok I need to check this. When do you get page of size "0" generally when 500 or 404 error occures an html page is generated as well? How do you get such error? > 5.) Interface to set_header. > > In cppcms::application set_header takes a pointer to HTTPHeader. When I look > into cppcms::worker_thread::set_header I see that a auto_ptr is taking > ownership of this pointer. Maybe the documentation points out that too, but > it would be much clearer if the the auto_ptr is used in the interface. Having > that, it would be easy to see that you can pass a fresh allocated object > without having to worry what will happen. So it should read: > > void set_header(std::auto_ptr<cgicc::HTTPHeader> h) { worker.set_header(h); } > I am absolutly agree, but I must admit that all http headers stuff is quite conceptually broken because of very bad design of CgiCC library CppCMS uses. It is totally rewritten in CppCMS 1.x.x HTTP/1.1 404 Not found Date: Tue, 27 Oct 2009 13:46:24 GMT Server: Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 X-Powered-By: cppcms/0.0.4 Content-Length: 248 Connection: close Content-Type: text/plain <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" Ok I'll check this. Best, Artyom |
From: Artyom <art...@ya...> - 2009-10-27 21:13:16
|
> For 500 internal server errors, 404 document not found and so on the > Content-Type is text/plain even though a html page is shown[0]. Thank you for bug report. Fixed in trunk. You are welcome to take the latest version from SVN. Artyom. P.S.: This bug just makes me even more convinced that CgiCC should be dropped away. |
From: Markus R. <us...@ma...> - 2009-10-28 18:15:32
|
Artyom wrote: >> Can someone explain me how to use cppcms_run for a production release or >> is it not suitable for that? > > Defenatly not. cppcms_run is just tool for debugging and testing the > framework agains different web servers. Thanks for making that clear. I have to admit that it is great tool for debugging and testing! > For example. This is configuration of production CppCMS wiki service for > lighttpd. Thank you for your configuration and explanation! I am not sure at the moment which server to use. >> I am a bit confused why the document root is an absolut path, while the >> fcgi process must be relative: >> /usr/local/bin/cppcms_run: line 474: ./MY_ABS_PATH/hello.fcgi: File not >> found (so ./ is prefixed there) > > It is just because I'm too lazy to write full path. So cppcms_run assumes > that the script is placed in current working directory and it names script > -- the base path according to program name by default. Ok, this makes perfectly sense when it is used for debugging. >> 2.) How can I run the site at the root of the server? >> >> When I use -s /hello, I can access the site at >> http://markusbyte:8080/hello/. How can I completely avoid the /hello/ to >> access the site at http://markusbyte:8080/. >> >> I hope it can be done without rewrite rules. It would be perfect if there >> is a webserver independend way? > > > Generally it is **bad** idea. And I explain why. Web server does much more > then providing fast-cgi service it also serves files. If hello is related > to / then if you want to get a file "/hello.css" you need to know how to > serve it VIA your program, and beleve me YOU DO NOT want to do this > because serving files has LOTs of security issues that should be handled > correctly. It is easy to give exceptions that specific paths or file extensions are not handeled by a fcgi program. At least with mod_rewrite for apache. I absolutely agree that for a normal web application or cms the normal file delievery should be done by the web server because of the security issues. But for the project I am writing these security issues do not exist. All files are in a single directory where the user has only read, but no write permissions. For my system it is not possible to distinguish between content and media files, because all can be delieverd as they are or rendered to html files. Besides that I want full control over the delievery and want my own code to design what to do with a specific mime type and so on. Delievering everything myself also makes it possible to have a global caching strategy for all files. I also want syndication for all directories. The file delievery already works btw. > Generally you may specify as script "/", but some web servers have problem > with that. I tried it with nginx and apache2 and it did not work for both. >> 3.) Using filters in other classes than base_view. >> >> The filters like escape can be only used in base_view classes (or classes >> inheriting from it) and I don't see any reason why. In addition to that >> there are not const, but they don't modify the object (they just return a >> string). >> > > They are not const but some filter may be non-const. Just think that you > may to access DB from filter if cache is not avalible (not that it is > correct way to do this) const only refers to the state of the object, not to global sideeffects like network or database. For caching you can use the keyword mutable. >> I would suggest to make them as functions or static methods. >> --------- > > In CppCMS 1.x.x they are static methods. Ok, this is perfect then. Up to that I need a copy of encode in my code. > There is one more important quite technical point why these functions are > members. I have not used filters enough up to yet. But I am sure creating your own filters can be very handy. >> 4.) Wrong mime type for failure pages. >> >> For 500 internal server errors, 404 document not found and so on the >> Content-Type is text/plain even though a html page is shown[0]. > > Ok I need to check this. When do you get page of size "0" generally when > 500 or 404 error occures an html page is generated as well? How do you > get such error? There is a telnet session at the end. Do you need other information? >> 5.) Interface to set_header. >> >> In cppcms::application set_header takes a pointer to HTTPHeader. When I >> look into cppcms::worker_thread::set_header I see that a auto_ptr is >> taking ownership of this pointer. Maybe the documentation points out that >> too, but it would be much clearer if the the auto_ptr is used in the >> interface. Having that, it would be easy to see that you can pass a fresh >> allocated object without having to worry what will happen. So it should >> read: >> >> void set_header(std::auto_ptr<cgicc::HTTPHeader> h) { >> worker.set_header(h); } >> > > I am absolutly agree, but I must admit that all http headers stuff is > quite conceptually broken because of very bad design of CgiCC library > CppCMS uses. It is totally rewritten in CppCMS 1.x.x Ok, now I can't await CppCMS 1.x.x :-) thank you Markus Raab -- http://www.markus-raab.org | Einsicht ist der erste Schritt zur -o) | Besserung. -- Sprichwort Kernel 2.6.24-1-a /\ | on a x86_64 _\_v | |
From: Artyom <art...@ya...> - 2009-10-28 20:23:39
|
> I tried it with nginx and apache2 and it did not work for both. I've made a little test with root "/" with cppcms_run as is - nginx worked but you should assume that path does not start with "/foo" but rather with "foo" - apache didn't want to accept my rules but it looks like problem of configuration Generally you should refer to the web server fast_cgi configuration to make service work from "/". When CppCMS recieves a request it uses "PATH_INFO" CGI variable for matching the URLs so if PATH_INFO is provided correctly it should work. Its a metter of correct web server configuration. > The file delievery already works btw. BTW CppCMS 1.x.x have its own internal web server and allows file hosting for development purposes only. See: http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/branches/refactoring/internal_file_server.h?revision=770&view=markup http://cppcms.svn.sourceforge.net/viewvc/cppcms/framework/branches/refactoring/internal_file_server.cpp?revision=790&view=markup It may give you some ideas how could this look like in next version. File Server itself is internal but it can be used as base for such application. In any case, serving files efficiently is **very** hard task, and I would recommend you relay on web server that can use functions like sendfile. Or at least try to use features like X-Send-File header of lighttp and nginx. Because, be shure they do it better then you can write with best cache. > I have not used filters enough up to yet. But I am sure creating your own > filters can be very handy. Take a look on Wikipp it has "markdown" filter that is used for formattng pages. Also I > There is a telnet session at the end. Do you need other information? As I send in previous mail. Thanks for the bug report. Fixed in trunk. > Ok, now I can't await CppCMS 1.x.x :-) Me too ;) Artyom. |
From: Markus R. <us...@ma...> - 2009-10-28 22:03:55
|
Artyom wrote: > >> I tried it with nginx and apache2 and it did not work for both. > > I've made a little test with root "/" with cppcms_run as is > > - nginx worked but you should assume that path does not start with "/foo" > but rather with "foo" Could you give me the cppcms_run arguments? 1.) cppcms_run -h markusbyte -s /hello hello.fcgi -c config.txt 2.) cppcms_run -h markusbyte -s / hello.fcgi -c config.txt 1. line works here (below hello), but for 2. line nginx gives a 404 on any request. > - apache didn't want to accept my rules but it looks > like problem of configuration Ok, at the moment it would be enough if I get any server running with root "/". > Generally you should refer to the web server fast_cgi configuration to > make service work from "/". > [...] I will take a look at it. >> The file delievery already works btw. > > BTW CppCMS 1.x.x have its own internal web server and allows file hosting > for development purposes only. > > See: > [...] > > It may give you some ideas how could this look like in next version. File > Server itself is internal but it can be used as base for such application. Interesting, your code looks like a complete duplicate of mine (or the other way round) :-) I also used a map for the mime_types checking against extension() and for copying I also used the read and write and even the same buffer size :-) However I plan for the future to use shared-mime-info, which has much more complete information about mime-types. Why is this internal file server needed? > In any case, serving files efficiently is **very** hard task, and I would > recommend you relay on web server that can use functions like sendfile. Or > at least try to use features like X-Send-File header of lighttp and nginx. > Because, be shure they do it better then you can write with best cache. If there are performance issues I can use the X-Send-File feature, thank you for the hint. >> I have not used filters enough up to yet. But I am sure creating your own >> filters can be very handy. > > Take a look on Wikipp it has "markdown" filter that is used for formattng > pages. Ohh, thank you, I think I can use that markdown2html. Supporting a wiki syntax is the first extra feature on my wish list. best regards Markus Raab -- http://www.markus-raab.org | Glücklicher als der Glücklichste ist, wer -o) | andere Menschen glücklich machen kann. -- Kernel 2.6.24-1-a /\ | Alexandre Dumas on a x86_64 _\_v | |
From: Stanimir M. <sta...@zo...> - 2009-11-21 15:05:49
|
Did you managed to run any server running with root "/"? My goal is when someone types www.hostname.com to be forwarded automatically to www.hostname.com/index trough the cppcms mapping for the index page. Here is my lighty.conf server.modules += ("mod_fastcgi") server.document-root = "/home/stanimir/projects/cppcmstest/build" mimetype.assign = ( ".pdf" => "application/pdf", # default mime type "" => "application/octet-stream", ) server.port = 80 server.bind = "www.hostname.com" $HTTP["host"] == "www.hostname.com" { url.rewrite-once => ( "^/$" => "/index" ), fastcgi.server = ( "/" => (( "bin-path" => "/home/stanimir/projects/cppcmstest/build/cppcmstest.fcgi -c /home/stanimir/projects/cppcmstest/build/config.txt", "check-local" => "disable", "socket" => "/tmp/cppcmstest.fcgi.socket", "max-procs" => 1 ))) } I am asking because now I want to do the same and with lighttpd i have NO success. With a prefix like "/myapp/" it works but you have to type www.hostname.com/myapp/index. Stanimir On Thu, Oct 29, 2009 at 12:02 AM, Markus Raab <us...@ma...> wrote: > Artyom wrote: > >> >>> I tried it with nginx and apache2 and it did not work for both. >> >> I've made a little test with root "/" with cppcms_run as is >> >> - nginx worked but you should assume that path does not start with "/foo" >> but rather with "foo" > > Could you give me the cppcms_run arguments? > 1.) cppcms_run -h markusbyte -s /hello hello.fcgi -c config.txt > 2.) cppcms_run -h markusbyte -s / hello.fcgi -c config.txt > > 1. line works here (below hello), but for 2. line nginx gives a 404 on any > request. > >> - apache didn't want to accept my rules but it looks >> like problem of configuration > > Ok, at the moment it would be enough if I get any server running with > root "/". > >> Generally you should refer to the web server fast_cgi configuration to >> make service work from "/". >> [...] > > I will take a look at it. > >>> The file delievery already works btw. >> >> BTW CppCMS 1.x.x have its own internal web server and allows file hosting >> for development purposes only. >> >> See: >> [...] >> >> It may give you some ideas how could this look like in next version. File >> Server itself is internal but it can be used as base for such application. > > Interesting, your code looks like a complete duplicate of mine (or the other > way round) :-) > > I also used a map for the mime_types checking against extension() and for > copying I also used the read and write and even the same buffer size :-) > > However I plan for the future to use shared-mime-info, which has much more > complete information about mime-types. > > Why is this internal file server needed? > >> In any case, serving files efficiently is **very** hard task, and I would >> recommend you relay on web server that can use functions like sendfile. Or >> at least try to use features like X-Send-File header of lighttp and nginx. >> Because, be shure they do it better then you can write with best cache. > > If there are performance issues I can use the X-Send-File feature, thank you > for the hint. > >>> I have not used filters enough up to yet. But I am sure creating your own >>> filters can be very handy. >> >> Take a look on Wikipp it has "markdown" filter that is used for formattng >> pages. > > Ohh, thank you, I think I can use that markdown2html. Supporting a wiki > syntax is the first extra feature on my wish list. > > > best regards > Markus Raab > > -- > http://www.markus-raab.org | Glücklicher als der Glücklichste ist, wer > -o) | andere Menschen glücklich machen kann. -- > Kernel 2.6.24-1-a /\ | Alexandre Dumas > on a x86_64 _\_v | > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry(R) Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Stanimir M. <sta...@zo...> - 2009-11-21 16:14:09
|
Hi, I must add that the problem is not in the configuration but in the regex in the url.add method. If the regex is url.add("(.*)", boost::bind<void>(&myapp::index,this,_1)); it works. However, when I try to display the binded argument it is an empty string. So I was not able to figure out what should be the regex for the mapping. Stanimir On Sat, Nov 21, 2009 at 5:05 PM, Stanimir Mladenov <sta...@zo...> wrote: > Did you managed to run any server running with root "/"? > > My goal is when someone types www.hostname.com to be forwarded > automatically to www.hostname.com/index trough the cppcms mapping for > the index page. > Here is my lighty.conf > > server.modules += ("mod_fastcgi") > server.document-root = "/home/stanimir/projects/cppcmstest/build" > mimetype.assign = ( > ".pdf" => "application/pdf", > # default mime type > "" => "application/octet-stream", > ) > > server.port = 80 > server.bind = "www.hostname.com" > $HTTP["host"] == "www.hostname.com" { > url.rewrite-once => ( "^/$" => "/index" ), > fastcgi.server = ( "/" => (( > "bin-path" => > "/home/stanimir/projects/cppcmstest/build/cppcmstest.fcgi -c > /home/stanimir/projects/cppcmstest/build/config.txt", > "check-local" => "disable", > "socket" => "/tmp/cppcmstest.fcgi.socket", > "max-procs" => 1 > ))) > } > > I am asking because now I want to do the same and with lighttpd i have > NO success. > With a prefix like "/myapp/" it works but you have to type > www.hostname.com/myapp/index. > > Stanimir > > On Thu, Oct 29, 2009 at 12:02 AM, Markus Raab <us...@ma...> wrote: >> Artyom wrote: >> >>> >>>> I tried it with nginx and apache2 and it did not work for both. >>> >>> I've made a little test with root "/" with cppcms_run as is >>> >>> - nginx worked but you should assume that path does not start with "/foo" >>> but rather with "foo" >> >> Could you give me the cppcms_run arguments? >> 1.) cppcms_run -h markusbyte -s /hello hello.fcgi -c config.txt >> 2.) cppcms_run -h markusbyte -s / hello.fcgi -c config.txt >> >> 1. line works here (below hello), but for 2. line nginx gives a 404 on any >> request. >> >>> - apache didn't want to accept my rules but it looks >>> like problem of configuration >> >> Ok, at the moment it would be enough if I get any server running with >> root "/". >> >>> Generally you should refer to the web server fast_cgi configuration to >>> make service work from "/". >>> [...] >> >> I will take a look at it. >> >>>> The file delievery already works btw. >>> >>> BTW CppCMS 1.x.x have its own internal web server and allows file hosting >>> for development purposes only. >>> >>> See: >>> [...] >>> >>> It may give you some ideas how could this look like in next version. File >>> Server itself is internal but it can be used as base for such application. >> >> Interesting, your code looks like a complete duplicate of mine (or the other >> way round) :-) >> >> I also used a map for the mime_types checking against extension() and for >> copying I also used the read and write and even the same buffer size :-) >> >> However I plan for the future to use shared-mime-info, which has much more >> complete information about mime-types. >> >> Why is this internal file server needed? >> >>> In any case, serving files efficiently is **very** hard task, and I would >>> recommend you relay on web server that can use functions like sendfile. Or >>> at least try to use features like X-Send-File header of lighttp and nginx. >>> Because, be shure they do it better then you can write with best cache. >> >> If there are performance issues I can use the X-Send-File feature, thank you >> for the hint. >> >>>> I have not used filters enough up to yet. But I am sure creating your own >>>> filters can be very handy. >>> >>> Take a look on Wikipp it has "markdown" filter that is used for formattng >>> pages. >> >> Ohh, thank you, I think I can use that markdown2html. Supporting a wiki >> syntax is the first extra feature on my wish list. >> >> >> best regards >> Markus Raab >> >> -- >> http://www.markus-raab.org | Glücklicher als der Glücklichste ist, wer >> -o) | andere Menschen glücklich machen kann. -- >> Kernel 2.6.24-1-a /\ | Alexandre Dumas >> on a x86_64 _\_v | >> >> >> ------------------------------------------------------------------------------ >> Come build with us! The BlackBerry(R) Developer Conference in SF, CA >> is the only developer event you need to attend this year. Jumpstart your >> developing skills, take BlackBerry mobile applications to market and stay >> ahead of the curve. Join us from November 9 - 12, 2009. Register now! >> http://p.sf.net/sfu/devconference >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > |
From: Artyom <art...@ya...> - 2009-11-21 16:29:51
|
> I must add that the problem is not in the configuration but > in the > regex in the url.add method. > If the regex is url.add("(.*)", > boost::bind<void>(&myapp::index,this,_1)); > it works. However, when I try to display the binded > argument it is an > empty string. The basic rule. When server matches url it splits it into "SCRIPT_NAME" and "PATH_INFO" Under lighttpd: For script "/foo": /foo/bar => "/foo" and "/bar" /foo/ => "/foo" and "/" /foo => "/foo" and "" For script "my_app.fcgi" it would be /some/path/my_app.fcgi/bar => "/some/path/my_app.fcgi" and "/bar" /my_app.fcgi => "/my_app.fcgi" and "" As far as I know for script "/" it does wired things... do not use it directly. Rather rewrite the URL to something like /bar => /foo/bar And use script "/foo" url.add ALWAYS matches against PATH_INFO. So in order to make url parsing work, make sure you get from the server the correct path info. For simplest debugging: url.add("^(.*)$",boost::bind(&myapp::index,this,_1)); Make sure you make the server sending correct PATH_INFO variable. Best, Artyom |
From: Stanimir M. <sta...@zo...> - 2009-11-24 09:34:47
|
Hello, Thanks for the guide, it helped a lot! Reading more deeply the documentation of lighttpd answered my question too, but after your help it was much easier. Greetings, Stanimir On Sat, Nov 21, 2009 at 6:29 PM, Artyom <art...@ya...> wrote: >> I must add that the problem is not in the configuration but >> in the >> regex in the url.add method. >> If the regex is url.add("(.*)", >> boost::bind<void>(&myapp::index,this,_1)); >> it works. However, when I try to display the binded >> argument it is an >> empty string. > > The basic rule. When server matches url it splits it into > "SCRIPT_NAME" and "PATH_INFO" > > Under lighttpd: > > For script "/foo": > > /foo/bar => "/foo" and "/bar" > /foo/ => "/foo" and "/" > /foo => "/foo" and "" > > For script "my_app.fcgi" it would be > > /some/path/my_app.fcgi/bar => "/some/path/my_app.fcgi" and "/bar" > /my_app.fcgi => "/my_app.fcgi" and "" > > As far as I know for script "/" it does wired things... do not > use it directly. Rather rewrite the URL to something like > /bar => /foo/bar > And use script "/foo" > > url.add ALWAYS matches against PATH_INFO. > > So in order to make url parsing work, make sure you get from the > server the correct path info. > > For simplest debugging: > > url.add("^(.*)$",boost::bind(&myapp::index,this,_1)); > > Make sure you make the server sending correct PATH_INFO > variable. > > Best, > Artyom > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Artyom <art...@ya...> - 2009-11-21 16:17:09
|
Hello, Shouldn't be > $HTTP["host"] == "www.hostname.com" { > url.rewrite-once => ( "^/$" > => "/index" ), url.rewrite-once => ("^(/.*)$" => "/index($1)") Or I no not understand you correctly. > fastcgi.server = ( "/" => Also I assume it should be "/index" instead of "/" I mean... Create rewrite rules that would convert anything from "/foo-bar" to "/index/foo-bar" and then make script "/index" and match with PATH_INFO for "/foo-bar" > > I am asking because now I want to do the same and with > lighttpd i have > NO success. > With a prefix like "/myapp/" it works but you have to type > www.hostname.com/myapp/index. What are matching patterns in your script? I mean urd.add(Pattern,XYZ) What do you use? > > Stanimir > > On Thu, Oct 29, 2009 at 12:02 AM, Markus Raab <us...@ma...> > wrote: > > Artyom wrote: > > > >> > >>> I tried it with nginx and apache2 and it did > not work for both. > >> > >> I've made a little test with root "/" with > cppcms_run as is > >> > >> - nginx worked but you should assume that path > does not start with "/foo" > >> but rather with "foo" > > > > Could you give me the cppcms_run arguments? > > 1.) cppcms_run -h markusbyte -s /hello hello.fcgi -c > config.txt > > 2.) cppcms_run -h markusbyte -s / hello.fcgi -c > config.txt > > > > 1. line works here (below hello), but for 2. line > nginx gives a 404 on any > > request. > > > >> - apache didn't want to accept my rules but it > looks > >> like problem of configuration > > > > Ok, at the moment it would be enough if I get any > server running with > > root "/". > > > >> Generally you should refer to the web server > fast_cgi configuration to > >> make service work from "/". > >> [...] > > > > I will take a look at it. > > > >>> The file delievery already works btw. > >> > >> BTW CppCMS 1.x.x have its own internal web server > and allows file hosting > >> for development purposes only. > >> > >> See: > >> [...] > >> > >> It may give you some ideas how could this look > like in next version. File > >> Server itself is internal but it can be used as > base for such application. > > > > Interesting, your code looks like a complete duplicate > of mine (or the other > > way round) :-) > > > > I also used a map for the mime_types checking against > extension() and for > > copying I also used the read and write and even the > same buffer size :-) > > > > However I plan for the future to use shared-mime-info, > which has much more > > complete information about mime-types. > > > > Why is this internal file server needed? > > > >> In any case, serving files efficiently is **very** > hard task, and I would > >> recommend you relay on web server that can use > functions like sendfile. Or > >> at least try to use features like X-Send-File > header of lighttp and nginx. > >> Because, be shure they do it better then you can > write with best cache. > > > > If there are performance issues I can use the > X-Send-File feature, thank you > > for the hint. > > > >>> I have not used filters enough up to yet. But > I am sure creating your own > >>> filters can be very handy. > >> > >> Take a look on Wikipp it has "markdown" filter > that is used for formattng > >> pages. > > > > Ohh, thank you, I think I can use that markdown2html. > Supporting a wiki > > syntax is the first extra feature on my wish list. > > > > > > best regards > > Markus Raab > > > > -- > > http://www.markus-raab.org | Glücklicher als der > Glücklichste ist, wer > > -o) | andere > Menschen glücklich machen kann. -- > > Kernel 2.6.24-1-a /\ | Alexandre Dumas > > on a x86_64 _\_v | > > > > > > > ------------------------------------------------------------------------------ > > Come build with us! The BlackBerry(R) Developer > Conference in SF, CA > > is the only developer event you need to attend this > year. Jumpstart your > > developing skills, take BlackBerry mobile applications > to market and stay > > ahead of the curve. Join us from November 9 - 12, > 2009. Register now! > > http://p.sf.net/sfu/devconference > > _______________________________________________ > > Cppcms-users mailing list > > Cpp...@li... > > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal > Reports 2008 30-Day > trial. Simplify your report design, integration and > deployment - and focus on > what you do best, core application coding. Discover what's > new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |