Skip to content

Configuration

bruno- edited this page Oct 3, 2014 · 12 revisions

This plugin works with minimal setup. However, configuration is possible.

In order to override the default, put the option in the stage file, example:

# in config/deploy/production.rb
set :unicorn_workers, 4

Nginx options

Defaults are listed near option name in the first line.

  • set :nginx_server_name # defaults to <server_IP>
    Your application's domain. The default is your server's IP address.

  • set :nginx_pid, "/run/nginx.pid"
    Path for nginx process pid file.

  • set :nginx_location, "/etc/nginx"
    Nginx installation directory.

SSL related options:

  • set :nginx_use_ssl, false
    If set to true, nginx will be configured to 443 port and port 80 will be auto routed to 443. Also, on nginx:setup, paths to ssl certificate and key will be configured. Certificate file and key will be uploaded to /etc/ssl/certs/ and /etc/ssl/private/ directories on the server.

  • set :nginx_upload_local_cert, true
    If true, certificates will be uploaded from a local path. Otherwise, it is expected for the certificate and key defined in the next 2 variables to be already on the server.

  • set :nginx_ssl_cert, "#{fetch(:nginx_server_name)}.crt"
    Remote file name of the certificate. Only makes sense if nginx_use_ssl is set.

  • set :nginx_ssl_cert_key, "#{fetch(:nginx_server_name)}.key"
    Remote file name of the certificate. Only makes sense if nginx_use_ssl is set.

  • set :nginx_ssl_cert_local_path # no default, required if nginx_use_ssl = true and nginx_upload_local_cert = true
    Local path to file with certificate. Only makes sense if nginx_use_ssl is set. This file will be copied to remote server. Example value: set :nginx_ssl_cert_local_path, "/home/user/ssl/myssl.cert"

  • set :nginx_ssl_cert_key_local_path # no default
    Local path to file with certificate key. Only makes sense if nginx_use_ssl is set. This file will be copied to remote server. Example value: set :nginx_ssl_cert_key_local_path, "/home/user/ssl/myssl.key"

Unicorn options

Defaults are listed near option name in the first line.

  • set :unicorn_service, "unicorn_#{fetch(:application)}_#{fetch(:stage)}
    Unicorn service name is unicorn_myapp_production by default.

  • set :unicorn_pid, shared_path.join("tmp/pids/unicorn.pid")
    Path for unicorn process pid file.

  • set :unicorn_config, shared_path.join("config/unicorn.rb")
    Path for unicorn config file.

  • set :unicorn_workers, 2
    Number of unicorn workers.

  • set :unicorn_app_env
    Set to the value of rails_env (for compatibility with capistrano-rails gem or stage option.

  • set :unicorn_use_tcp, -> { roles(:app).count > 1 }

    • true if there are multiple app servers. nginx and unicorn communicate over tcp port.
    • false for single node configuration. nginx and unicorn communicate over unix socket.
  • set :unicorn_tcp_listen_port, 8080
    Specifies tcp port when unicorn_use_tcp is true.

Clone this wiki locally