-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnginx-proxy.conf.erb
More file actions
51 lines (42 loc) · 1.27 KB
/
Copy pathnginx-proxy.conf.erb
File metadata and controls
51 lines (42 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<% if @backends.length > 0 %>
upstream <%= @formation %>-backends {
<% if @algorithm == "least_conn" %>
# route requests based on least number of connections
# see http://nginx.org/en/docs/http/ngx_http_upstream_module.html#least_conn
least_conn;
<% elsif @algorithm == "ip_hash" %>
# route requests to the same web worker based on hash of their IP addr
# see http://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash
ip_hash;
<% else %>
# route requests using a simple round robin scheme
<% end %>
# web worker format: public_fqdn:public_port
<% @backends.each do |backend| %>
server <%= backend %>;
<% end %>
}
<% end %>
server {
listen <%= @port %> default_server;
# Make site accessible from http://localhost/
server_name localhost;
<% if @backends.length > 0 %>
location / {
proxy_pass http://<%= @formation %>-backends;
<% if @firewall %>
# Nginx Anti XSS & SQL Injection (Web Application Firewall)
# see https://code.google.com/p/naxsi/ for more info
include /etc/nginx/naxsi.rules;
<% end %>
}
<% end %>
# TODO: allow configurable error pages
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
}