summaryrefslogtreecommitdiff
path: root/templates/site-ssl.erb
blob: 11a69ddcae570a0956a72992785a70474fd237a3 (plain)
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
<% if @cache == true -%>
proxy_cache_path /var/cache/nginx/<%= @name %> levels=<%= @cache_levels %> keys_zone=<%= @name %>:<%= @cache_size %> inactive=<%= @cache_inactive %> max_size=<%= @cache_max_size %>;
<% end -%>
<% if @rate_limit == true and @rate_limit_zone == @server_name -%>
limit_req_zone <%= @rate_limit_key %> zone=<%= @rate_limit_zone %>:<%= @rate_limit_size %> rate=<%= @rate_limit_rate %>;
<% end -%>
server {
  listen      443;
  server_name <%= @server_name %> <%= @aliases %>;

  ssl on;
  ssl_certificate     /etc/letsencrypt/live/<%= @server_name %>/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/<%= @server_name %>/privkey.pem;

  # enable HSTS header
  add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload";

  # clickjacking protection
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Frame-Options <%= @x_frame_options %>;

  location / {
    # preserve http header and set forwarded proto
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto https;

    # default proxy pass
    proxy_pass       http://<%= @backend %>:80;
<% if @cache == true -%>

    # cache config
    proxy_cache <%= @name %>;
<% end -%>
<% if @rate_limit == true -%>

    # rate limiting
    limit_req zone=<%= @rate_limit_zone %>;
<% end -%>
  }
}