.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Catalyst::Manual::Deployment::nginx::FastCGI 3pm" .TH Catalyst::Manual::Deployment::nginx::FastCGI 3pm "2020-07-25" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Catalyst::Manual::Deployment::nginx::FastCGI \- Deploying Catalyst with nginx .SH "nginx" .IX Header "nginx" Catalyst runs under nginx via FastCGI in a similar fashion as the lighttpd standalone server. .PP nginx does not have its own internal FastCGI process manager, so you must run the FastCGI service separately. .SS "Configuration" .IX Subsection "Configuration" To configure nginx, you must configure the FastCGI parameters and also the socket your FastCGI daemon is listening on. It can be either a \s-1TCP\s0 socket or a Unix file socket. .PP The server configuration block should look roughly like: .PP .Vb 2 \& server { \& listen $port; \& \& location / { \& fastcgi_param QUERY_STRING $query_string; \& fastcgi_param REQUEST_METHOD $request_method; \& fastcgi_param CONTENT_TYPE $content_type; \& fastcgi_param CONTENT_LENGTH $content_length; \& \& fastcgi_param SCRIPT_NAME \*(Aq\*(Aq; \& fastcgi_param PATH_INFO $fastcgi_script_name; \& fastcgi_param REQUEST_URI $request_uri; \& fastcgi_param DOCUMENT_URI $document_uri; \& fastcgi_param DOCUMENT_ROOT $document_root; \& fastcgi_param SERVER_PROTOCOL $server_protocol; \& \& fastcgi_param GATEWAY_INTERFACE CGI/1.1; \& fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; \& \& fastcgi_param REMOTE_ADDR $remote_addr; \& fastcgi_param REMOTE_PORT $remote_port; \& fastcgi_param SERVER_ADDR $server_addr; \& fastcgi_param SERVER_PORT $server_port; \& fastcgi_param SERVER_NAME $server_name; \& \& # Adjust the socket for your applications! \& fastcgi_pass unix:$docroot/myapp.socket; \& } \& } .Ve .PP It is the standard convention of nginx to include the fastcgi_params in a separate file (usually something like \f(CW\*(C`/etc/nginx/fastcgi_params\*(C'\fR) and simply include that file. .PP If you include the \f(CW\*(C`/etc/nginx/fastcgi_params\*(C'\fR that comes with your distribution, e.g. Debian, you need to adjust a couple of parameters for \s-1PSGI\s0 compatibility, use something like this: .PP .Vb 3 \& include /etc/nginx/fastcgi_params; \& fastcgi_param SCRIPT_NAME \*(Aq\*(Aq; \& fastcgi_param PATH_INFO $fastcgi_script_name; .Ve .SS "Non-root configuration" .IX Subsection "Non-root configuration" If you properly specify the \s-1PATH_INFO\s0 and \s-1SCRIPT_NAME\s0 parameters your application will be accessible at any path. The \s-1SCRIPT_NAME\s0 variable is the prefix of your application, and \s-1PATH_INFO\s0 would be everything in addition. .PP As an example, if your application is rooted at /myapp, you would configure: .PP .Vb 7 \& rewrite ^/myapp$ /myapp/ permanent; \& location /myapp/ { \& include /etc/nginx/fastcgi_params; \& fastcgi_param SCRIPT_NAME /myapp/; \& fastcgi_param PATH_INFO $fastcgi_script_name; \& fastcgi_pass unix:/tmp/myapp.socket; \& } .Ve .PP \&\f(CW$fastcgi_script_name\fR would be \*(L"/myapp/path/of/the/action\*(R". Catalyst will process this accordingly and setup the application base as expected. .PP This behavior is somewhat different from Apache and lighttpd, but is still functional. .PP Note that the rewrite may not be needed with newer versions of nginx, and the paths must be exactly as specified \- the trailing slash in the location block and the \s-1SCRIPT_NAME\s0 are important. .SS "\s-1SSL\s0" .IX Subsection "SSL" Make sure that nginx passes this to your fastcgi. To ensure this, you need the following in your nginx config for the \s-1SSL\s0 vhost: .PP .Vb 1 \& fastcgi_param HTTPS on .Ve .SH "MORE INFO" .IX Header "MORE INFO" For more information on nginx, visit: .SH "AUTHORS" .IX Header "AUTHORS" Catalyst Contributors, see Catalyst.pm .SH "COPYRIGHT" .IX Header "COPYRIGHT" This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.