Created
April 13, 2014 17:55
-
-
Save togume/10594736 to your computer and use it in GitHub Desktop.
Node Behind Nginx Chef Template and Recipe Call
This file contains hidden or 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
# Recipe Call | |
template "#{node[:nginx][:dir]}/sites-available/<app_name>" do | |
source "nginx_node_app.erb" | |
owner "root" | |
group "root" | |
mode 0644 | |
variables( | |
:app_name => "<app_name>", | |
:app_port => "<app_port>", | |
:app_domains => "<app_domains>" | |
) | |
end | |
# Template Contents | |
upstream <%= @params[:app_name] %> { | |
ip_hash; | |
server localhost:<%= @params[:app_port] %> weight=10 max_fails=3 fail_timeout=30s; # Reverse proxy to localhost | |
} | |
server { | |
listen 80; | |
server_name <%= @params[:app_domains] %>; | |
access_log /var/log/nginx/nginx.access.<%= @params[:app_name] %>.log; | |
error_log /var/log/nginx/nginx_error.<%= @params[:app_name] %>.log debug; | |
location / { | |
proxy_pass http://<%= @params[:app_name] %>; # Load balance the URL location "/" to the upstream lb-subprint | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /var/www/nginx-default; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment