
I've spent a bit of time trying to setup a yesod app under nginx using fastcgi. The server config looks a little like this (statics get served by nginx which is nice) server { listen 80; server_name domain.com; access_log # error_log # location ~ ^/s/.* { root /path/to/static/static; } location ~ ^/ { include /etc/nginx/fastcgi_params; fastcgi_pass http://127.0.0.1:3000; } } unfortunately I couldn't get the wai-handler-fastcgi package to run properly. Server: user error (FCGX_Accept failed with error code: -88) I couldn't find error code -88 easily and I am guessing that I need to set a particular port for the app to run on, unfortunately I didn't see any way to do this through the wai api? (it does appear the wai-handler-snap's run function takes an Int...) I'm just a little confused at the moment. Regards, Mark

okay so my config is a little off (don't need the http://). But
non-the-less I cannot seem to find a way to start a yesod app as a
fastcgi process (I don't really have and experience with fastcgi).
Apparently apache and lighttpd start fastcgi processes for you so they
don't have my problem, but I at least want to give nginx a go.
Mark
On Mon, Jul 26, 2010 at 7:36 PM, Mark Bradley
I've spent a bit of time trying to setup a yesod app under nginx using fastcgi. The server config looks a little like this (statics get served by nginx which is nice)
server { listen 80; server_name domain.com;
access_log # error_log #
location ~ ^/s/.* { root /path/to/static/static; }
location ~ ^/ { include /etc/nginx/fastcgi_params; fastcgi_pass http://127.0.0.1:3000; } }
unfortunately I couldn't get the wai-handler-fastcgi package to run properly.
Server: user error (FCGX_Accept failed with error code: -88)
I couldn't find error code -88 easily and I am guessing that I need to set a particular port for the app to run on, unfortunately I didn't see any way to do this through the wai api? (it does appear the wai-handler-snap's run function takes an Int...)
I'm just a little confused at the moment.
Regards, Mark

OK, I had to do a little research into this one: I've never used nginx, only
lighttpd and Apache. Both of those automatically spawn the FastCGI process.
Basically, the FastCGI spec requires file descriptor 0 to be a socket for
receiving the incoming connections. When lighttpd or Apache spawn a FastCGI
process, they handle all of the "fun parts" themselves. With nginx, we'll
have to do it ourselves.
I've attached a C file called "runner.c" which creates a socket, binds it to
a port, calls dup2 to replace stdin with this new socket and then execs a
new application (called "bind" here). You should be able to replace "1100"
with your desired port number and "bind" with your application name and it
will run your FastCGI script appropriately.
Obviously, this is a suboptimal solution; it would be nice if the FastCGI
handler did all of this stuff for us. I'll toy around with that and see if I
can get anything working. Please let me know if this solution works; if so,
could you send me you nginx config file? I've been wanting to try it out as
a replacement for lighttpd.
Michael
On Mon, Jul 26, 2010 at 3:44 PM, Mark Bradley
okay so my config is a little off (don't need the http://). But non-the-less I cannot seem to find a way to start a yesod app as a fastcgi process (I don't really have and experience with fastcgi).
Apparently apache and lighttpd start fastcgi processes for you so they don't have my problem, but I at least want to give nginx a go.
Mark
I've spent a bit of time trying to setup a yesod app under nginx using fastcgi. The server config looks a little like this (statics get served by nginx which is nice)
server { listen 80; server_name domain.com;
access_log # error_log #
location ~ ^/s/.* { root /path/to/static/static; }
location ~ ^/ { include /etc/nginx/fastcgi_params; fastcgi_pass http://127.0.0.1:3000; } }
unfortunately I couldn't get the wai-handler-fastcgi package to run
On Mon, Jul 26, 2010 at 7:36 PM, Mark Bradley
wrote: properly. Server: user error (FCGX_Accept failed with error code: -88)
I couldn't find error code -88 easily and I am guessing that I need to set a particular port for the app to run on, unfortunately I didn't see any way to do this through the wai api? (it does appear the wai-handler-snap's run function takes an Int...)
I'm just a little confused at the moment.
Regards, Mark
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

Of course, there's always the easy way: spawn-fcgi[1]. I just stumbled upon
it, this seems like the "right way."
Using this, I think I'll try to add a nginx section to the deploying
page[2], and maybe even get some benchmarks between lighttpd and nginx.
Seems like Cherokee could also fit the bill here.
[1] http://redmine.lighttpd.net/projects/spawn-fcgi
http://redmine.lighttpd.net/projects/spawn-fcgi[2]
http://docs.yesodweb.com/yesod/deploying.html
On Mon, Jul 26, 2010 at 4:52 PM, Michael Snoyman
OK, I had to do a little research into this one: I've never used nginx, only lighttpd and Apache. Both of those automatically spawn the FastCGI process.
Basically, the FastCGI spec requires file descriptor 0 to be a socket for receiving the incoming connections. When lighttpd or Apache spawn a FastCGI process, they handle all of the "fun parts" themselves. With nginx, we'll have to do it ourselves.
I've attached a C file called "runner.c" which creates a socket, binds it to a port, calls dup2 to replace stdin with this new socket and then execs a new application (called "bind" here). You should be able to replace "1100" with your desired port number and "bind" with your application name and it will run your FastCGI script appropriately.
Obviously, this is a suboptimal solution; it would be nice if the FastCGI handler did all of this stuff for us. I'll toy around with that and see if I can get anything working. Please let me know if this solution works; if so, could you send me you nginx config file? I've been wanting to try it out as a replacement for lighttpd.
Michael
On Mon, Jul 26, 2010 at 3:44 PM, Mark Bradley
wrote: okay so my config is a little off (don't need the http://). But non-the-less I cannot seem to find a way to start a yesod app as a fastcgi process (I don't really have and experience with fastcgi).
Apparently apache and lighttpd start fastcgi processes for you so they don't have my problem, but I at least want to give nginx a go.
Mark
I've spent a bit of time trying to setup a yesod app under nginx using fastcgi. The server config looks a little like this (statics get served by nginx which is nice)
server { listen 80; server_name domain.com;
access_log # error_log #
location ~ ^/s/.* { root /path/to/static/static; }
location ~ ^/ { include /etc/nginx/fastcgi_params; fastcgi_pass http://127.0.0.1:3000; } }
unfortunately I couldn't get the wai-handler-fastcgi package to run
On Mon, Jul 26, 2010 at 7:36 PM, Mark Bradley
wrote: properly. Server: user error (FCGX_Accept failed with error code: -88)
I couldn't find error code -88 easily and I am guessing that I need to set a particular port for the app to run on, unfortunately I didn't see any way to do this through the wai api? (it does appear the wai-handler-snap's run function takes an Int...)
I'm just a little confused at the moment.
Regards, Mark
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
participants (2)
-
Mark Bradley
-
Michael Snoyman