3 Catalyst::Manual::Deployment::nginx::FastCGI - Deploying Catalyst with nginx
7 Catalyst runs under nginx via FastCGI in a similar fashion as the lighttpd
10 nginx does not have its own internal FastCGI process manager, so you must run
11 the FastCGI service separately.
15 To configure nginx, you must configure the FastCGI parameters and also the
16 socket your FastCGI daemon is listening on. It can be either a TCP socket
17 or a Unix file socket.
19 The server configuration block should look roughly like:
25 fastcgi_param QUERY_STRING $query_string;
26 fastcgi_param REQUEST_METHOD $request_method;
27 fastcgi_param CONTENT_TYPE $content_type;
28 fastcgi_param CONTENT_LENGTH $content_length;
30 fastcgi_param SCRIPT_NAME '';
31 fastcgi_param PATH_INFO $fastcgi_script_name;
32 fastcgi_param REQUEST_URI $request_uri;
33 fastcgi_param DOCUMENT_URI $document_uri;
34 fastcgi_param DOCUMENT_ROOT $document_root;
35 fastcgi_param SERVER_PROTOCOL $server_protocol;
37 fastcgi_param GATEWAY_INTERFACE CGI/1.1;
38 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
40 fastcgi_param REMOTE_ADDR $remote_addr;
41 fastcgi_param REMOTE_PORT $remote_port;
42 fastcgi_param SERVER_ADDR $server_addr;
43 fastcgi_param SERVER_PORT $server_port;
44 fastcgi_param SERVER_NAME $server_name;
46 # Adjust the socket for your applications!
47 fastcgi_pass unix:$docroot/myapp.socket;
51 It is the standard convention of nginx to include the fastcgi_params in a
52 separate file (usually something like C</etc/nginx/fastcgi_params>) and
53 simply include that file.
55 If you include the C</etc/nginx/fastcgi_params> that comes with your
56 distribution, e.g. Debian, you need to adjust a couple of parameters for PSGI
57 compatibility, use something like this:
59 include /etc/nginx/fastcgi_params;
60 fastcgi_param SCRIPT_NAME '';
61 fastcgi_param PATH_INFO $fastcgi_script_name;
63 =head2 Non-root configuration
65 If you properly specify the PATH_INFO and SCRIPT_NAME parameters your
66 application will be accessible at any path. The SCRIPT_NAME variable is the
67 prefix of your application, and PATH_INFO would be everything in addition.
69 As an example, if your application is rooted at /myapp, you would configure:
71 rewrite ^/myapp$ /myapp/ permanent;
73 include /etc/nginx/fastcgi_params;
74 fastcgi_param SCRIPT_NAME /myapp/;
75 fastcgi_param PATH_INFO $fastcgi_script_name;
76 fastcgi_pass unix:/tmp/myapp.socket;
79 C<$fastcgi_script_name> would be "/myapp/path/of/the/action". Catalyst will
80 process this accordingly and setup the application base as expected.
82 This behavior is somewhat different from Apache and lighttpd, but is still
85 Note that the rewrite may not be needed with newer versions of nginx,
86 and the paths must be exactly as specified - the trailing slash in the
87 location block and the SCRIPT_NAME are important.
91 Make sure that nginx passes this to your fastcgi. To ensure this, you need
92 the following in your nginx config for the SSL vhost:
94 fastcgi_param HTTPS on
98 For more information on nginx, visit:
103 Catalyst Contributors, see Catalyst.pm
107 This library is free software. You can redistribute it and/or modify it under
108 the same terms as Perl itself.