Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Make nginx listen ports configurable #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ set :nginx_server_name, "example.com"
set :nginx_pid, "/run/nginx.pid"

# if set, nginx will be configured to 443 port and port 80 will be auto rewritten to 443
# set `nginx_http_port` and `nginx_https_port` if you need to change these ports
# also, on `nginx:setup`, paths to ssl certificate and key will be configured
# and certificate file and key will be copied to `/etc/ssl/certs` and `/etc/ssl/private/` directories
# default value: false
# default value: false.
set :nginx_use_ssl, false

# if set, it will ask to upload certificates from a local path. Otherwise, it will expect
Expand All @@ -117,6 +118,12 @@ set :nginx_ssl_certificate_key, "#{nginx_server_name}.key"
# default value: `/etc/nginx/sites-available`
set :nginx_config_path, "/etc/nginx/sites-available"

# nginx http listen port
set :nginx_http_port, 80

# nginx https listen port
set :nginx_http_port, 443

# path, where unicorn pid file will be stored
# default value: `"#{current_path}/tmp/pids/unicorn.pid"`
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
Expand Down
2 changes: 2 additions & 0 deletions lib/capistrano/nginx_unicorn/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
set :nginx_ssl_certificate_local_path, -> { ask(:nginx_ssl_certificate_local_path, "Local path to ssl certificate: ") }
set :nginx_ssl_certificate_key_local_path, -> { ask(:nginx_ssl_certificate_key_local_path, "Local path to ssl certificate key: ") }
set :nginx_config_path, "/etc/nginx/sites-available"
set :nginx_http_port, 80
set :nginx_https_port, 443

set :unicorn_service_name, -> { "unicorn_#{fetch(:application)}_#{fetch(:stage)}" }
set :unicorn_pid, -> { shared_path.join("pids/unicorn.pid") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ server {

server {
<% if fetch(:nginx_use_ssl) %>
listen 443;
listen <%= fetch(:nginx_https_port) %>;
ssl on;
ssl_certificate /etc/ssl/certs/<%= fetch(:nginx_ssl_certificate) %>;
ssl_certificate_key /etc/ssl/private/<%= fetch(:nginx_ssl_certificate_key) %>;
<% else %>
listen 80;
listen <%= fetch(:nginx_http_port) %>;
<% end %>

client_max_body_size 4G;
Expand Down