This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the nginx cookbook to allow for multiple app servers and medi…
…a servers per project. Also updated the example configs to take advantage of this.
- Loading branch information
Showing
7 changed files
with
124 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,47 @@ | ||
upstream app_server_<%= node[:project_name] %> { | ||
server unix:/tmp/<%= node[:project_name] %>.gunicorn.sock fail_timeout=0; | ||
#server 127.0.0.1:8001 fail_timeout=0; | ||
# For a TCP configuration: | ||
# server 192.168.0.7:8000 fail_timeout=0; | ||
} | ||
|
||
server { | ||
listen 80; | ||
client_max_body_size 4G; | ||
server_name <%= node[:domain_names] %>; | ||
#server_name <%= node[:domain_names].each do |d| print "#{d} " end %>; | ||
<% node[:servers].each do |name, server_info| %> | ||
<% if server_info[:app_servers] %> | ||
<% server_info[:app_servers].each do |app_server| %> | ||
upstream app_server_<%= name %>_<%= app_server[:name] %> { | ||
<% if app_server[:socket_path] %> | ||
server unix:<%= app_server[:socket_path] %> fail_timeout=0; | ||
<% else %> | ||
server unix:/tmp/<%= app_server[:name] %>.gunicorn.sock fail_timeout=0; | ||
<% end %> | ||
} | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
access_log /var/log/nginx/<%= node[:project_name] %>/access.log; | ||
error_log /var/log/nginx/<%= node[:project_name] %>/error.log; | ||
sendfile on; | ||
<% node[:servers].each do |name, server_info| %> | ||
server { | ||
|
||
keepalive_timeout 5; | ||
server_name <%= server_info[:domains] %>; | ||
|
||
# path for static files | ||
root /var/www/<%= node[:project_name] %>; | ||
access_log /var/log/nginx/<%= name %>/access.log; | ||
error_log /var/log/nginx/<%= name %>/error.log; | ||
|
||
location / { | ||
<% if server_info[:app_servers] %> | ||
<% server_info[:app_servers].each do |app_server| %> | ||
location <%= app_server[:location] %> { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
|
||
if (!-f $request_filename) { | ||
proxy_pass http://app_server_<%= node[:project_name] %>; | ||
proxy_pass http://app_server_<%= name %>_<%= app_server[:name] %>; | ||
break; | ||
} | ||
} | ||
<% end %> | ||
<% end %> | ||
error_page 500 502 503 504 /500.html; | ||
location = /500.html { | ||
root /path/to/app/current/public; | ||
<% if server_info[:static_dirs] %> | ||
<% server_info[:static_dirs].each do |static_dir| %> | ||
location <%= static_dir[:location] %> { | ||
root <%= static_dir[:path] %>; | ||
} | ||
} | ||
<% end %> | ||
<% end %> | ||
|
||
} | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"run_list": [ "main", "python", "postgres"], | ||
"run_list": [ "main", "python", "postgres", "nginx"], | ||
"project_name": "local", | ||
"development_environment": true, | ||
"postgres_password": "postgres" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters