Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
definitions
features
recipes to do list Jun 1, 2012
templates/default смотри файл изменений. новая версия Nov 28, 2012
README.md doc update Nov 26, 2012
changes.md смотри файл изменений. новая версия Nov 28, 2012
metadata.rb Modify license agreement to Apache-2.0 May 7, 2018

README.md

Description

Creates nginx site to run your fastcgi application with nginx front-end

Requirements

Should work on any platform where nginx is installed. Tested on Ubuntu/Debian.

Limitations

fastcgi standalone server mode is only supported

DEFINITIONS

nginx_fastcgi

This definition can be used to create nginx site to run your fastcgi application with nginx front-end.

The definition takes the following parameters:

  • name: specifies a path for nginx site configuration file. No default, this must be specified.
  • socket: specifies unix socket of FastCGI server.
  • inet_socket: specifies inet socket of FastCGI server. No default. Choose either unix or inet socket.

Check out http://wiki.nginx.org/HttpFastcgiModule#fastcgi_pass for details.

  • static: specifies location of static files (to be handled by nginx). Array of Hashes or hash with following keys:
    • location
    • root
  • servers: specifies virtual hosts to be included into ngix site configuration. Array of Hashes with following keys:
    • ip
    • server_name
    • ssl
    • ssl_include_path
    • error_page
    • redirect
  • cookbook: specifies the cookbook with nginx site configuration template. Optional
  • fastcgi_param: specifies additional fastcgi params
  • error_page - specifies custom error pages. Array of Hashes with following keys:
  • code
  • handler

Check out http://wiki.nginx.org/HttpCoreModule#error_page for details

Usage cases

named virtual host, port 80

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    socket '/tmp/application.socket'
    servers [
        {
            :ip => '127.0.0.1',
            :server_name => 'foo.site.x'
        }
    ]
end

fastcgi running on inet socket

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    inet_socket 'localhost:9000'
    servers [
        {
            :ip => '127.0.0.1',
            :server_name => 'foo.site.x'
        }
    ]
end

ssl enabled virtual host

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    socket '/tmp/application.socket'
    servers [
        {
            :server_name => 'bar.site.x',
            :ssl => true,
            :ssl_include_path => 'nginx_ssl_settings.conf'
            
        }
    ]
end

set document root

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    root  '/var/www/MyApp/root'
    socket '/tmp/application.socket'
    servers [
        {
            :server_name => 'foo.site.x',
        }
    ]
end

enabling http -> https redirect

all http traffic get redirected to https host:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    socket '/tmp/application.socket'
    servers [
        {
            :ip => '127.0.0.1',
            :server_name => 'bar.site.x',
            :redirect => 'https'                
        },
        {
            :ip => '127.0.0.1',
            :server_name => 'bar.site.x',
            :ssl => true,
            :ssl_include_path => 'nginx_ssl_settings.conf'
        }
    ]
end

handling static files by nginx

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    socket '/tmp/application.socket'
    static(
            :location => 'static/',
            :root => '/var/www/MyApp/root'
    )
    servers [
        {
            :server_name => 'foo.site.x',
        }
    ]
end

set specific fastcgi params:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    socket '/tmp/application.socket'
    fastcgi_param  [
        { :name => 'SCRIPT_NAME', :value => "\"\"" },
        { :name => 'PATH_INFO' , :value => '$uri' }
    ]
    servers [
        {
            :server_name => 'foo.site.x',
        }
    ]
end

set error page, code 500

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
    socket '/tmp/application.socket'
    servers [
        {
            :server_name => 'foo.site.x'
        }
    ]
    error_page [
        {
            :code       => 500,
            :handler    => '/500.html'
        }
    ]
end

For complete examples of usage see https://github.com/melezhik/cookbooks/tree/master/nginx-fastcgi/features