[Catalyst] nginx configuration issues

Jesse Sheidlower jester at panix.com
Sun Nov 6 02:30:38 GMT 2011


I'm porting a site from Apache/mod_perl to nginx/FastCGI, and am having
some configuration problems whilst closely following the instructions in
the Cat docs and wiki (specifically,
Catalyst::Manual::Deployment::nginx::FastCGI and
http://wiki.catalystframework.org/wiki/adventcalendararticles/2008/02-catalyst_and_nginx
). There are already some updates to the docs I can make based on what
I've learned, and I'll incorporate anything I learn here as well.

I run several sites on the same server at non-root locations. Within my
main server {  } block, I add (for example):

       # SF citations site
       location /sf {
            include fastcgi_params; # stock Ubuntu file; overload as necessary
            fastcgi_param SCRIPT_NAME /sf/;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_pass   unix:/tmp/sf.socket;
       }

       location /sf/static {
            root /usr/local/www/modules/CatSF/root;
       }


The static location thing was taken from the Advent article. However,
it's not working; this config is trying to serve the files from
/usr/local/www/modules/CatSF/root/sf , i.e. inserting "sf" at the end.
What's the correct approach? For comparison, the Apache config I use for
this app is:

  PerlSwitches -I/usr/local/www/modules/CatSF/lib
  PerlModule CatSF
  <Location /sf>
          SetHandler          modperl
          PerlResponseHandler CatSF
  </Location>
  Alias /sf/static /usr/local/www/modules/CatSF/root/static
  <Directory /usr/local/www/modules/CatSF/root/static>
           allow from all
  </Directory>
  <Location /sf/static>
          SetHandler          default-handler
  </Location>

My second question is about the use of SSL. Most of my apps have
password logins that are wrapped with C::P::RequireSSL. In Apache, this
Just Worked; I didn't do anything, and https requests were handled
properly. In nginx, my SSL configuration is conflicting with this and
I'm not sure how to resolve it.

When I hit the main page without having logged in, it redirects to
the https version of the page, and I get a 404 with this error:

2011/11/06 02:19:02 [error] 23266#0: *62 open()
"/usr/local/www/data/incomings" failed (2: No such file or directory),
client: [blah], server: localhost, request: "GET /incomings
HTTP/1.1", host: "[blahblah]"

In other words, it's treating the request as a not-Catalyst request, as
this is the root of the server { } block that handles https:

  # HTTPS server
  server {
        listen 443;
        server_name localhost;

        root /usr/local/www/data;
        index index.html index.htm;
  [...]

How do I configure nginx to handle ssl requests for Cat apps through
Cat? And is there some neat way of handling the configuration, so that I
don't have to put it in two places (the regular server on 80 and the
https server on 443)? 

Thanks.



More information about the Catalyst mailing list