| OLD | NEW |
| 1 <% include_file = lambda do |url| %> | 1 <% include_file = lambda do |url| %> |
| 2 <% content = Puppet::FileServing::Content.indirection.find(url) %> | 2 <% content = Puppet::FileServing::Content.indirection.find(url) %> |
| 3 <% if content %> | 3 <% if content %> |
| 4 <%= content.content %> | 4 <%= content.content %> |
| 5 <% else %> | 5 <% else %> |
| 6 <% raise StandardError, "Failed to resolve source URL #{url}" %> | 6 <% raise StandardError, "Failed to resolve source URL #{url}" %> |
| 7 <% end %> | 7 <% end %> |
| 8 <% end %> | 8 <% end %> |
| 9 | 9 |
| 10 <% server_name = lambda do |domain, alt_names| %><%= domain %><% @alt_names.each
do |name| %>, <%= name %><% end %><% end %> | 10 <% server_name = lambda do |domain, alt_names| %><%= domain %><% @alt_names.each
do |name| %>, <%= name %><% end %><% end %> |
| 11 | 11 |
| 12 <% if global_config %> | 12 <% if @global_config %> |
| 13 <%= @global_config %> | 13 <%= @global_config %> |
| 14 <% end %> | 14 <% end %> |
| 15 | 15 |
| 16 <% if @certificate and @private_key %> | 16 <% if @certificate and @private_key %> |
| 17 server | 17 server |
| 18 { | 18 { |
| 19 server_name <% server_name[domain, alt_names] %>; | 19 server_name <% server_name[@domain, @alt_names] %>; |
| 20 | 20 |
| 21 <% if is_default %> | 21 <% if @is_default %> |
| 22 listen 80 default_server; | 22 listen 80 default_server; |
| 23 listen [::]:80 default_server; | 23 listen [::]:80 default_server; |
| 24 <% else %> | 24 <% else %> |
| 25 listen 80; | 25 listen 80; |
| 26 listen [::]:80; | 26 listen [::]:80; |
| 27 <% end %> | 27 <% end %> |
| 28 | 28 |
| 29 location / | 29 location / |
| 30 { | 30 { |
| 31 rewrite (.*) https://$host$1 permanent; | 31 rewrite (.*) https://$host$1 permanent; |
| 32 } | 32 } |
| 33 } | 33 } |
| 34 server | 34 server |
| 35 { | 35 { |
| 36 server_name <% server_name[domain, alt_names] %>; | 36 server_name <% server_name[@domain, @alt_names] %>; |
| 37 | 37 |
| 38 <% if is_default %> | 38 <% if @is_default %> |
| 39 listen 443 ssl http2 default_server; | 39 listen 443 ssl http2 default_server; |
| 40 listen [::]:443 ssl http2 default_server; | 40 listen [::]:443 ssl http2 default_server; |
| 41 <% else %> | 41 <% else %> |
| 42 listen 443 ssl http2; | 42 listen 443 ssl http2; |
| 43 listen [::]:443 ssl http2; | 43 listen [::]:443 ssl http2; |
| 44 <% end %> | 44 <% end %> |
| 45 | 45 |
| 46 ssl_certificate <%= certificate %>; | 46 ssl_certificate <%= @certificate %>; |
| 47 ssl_certificate_key <%= private_key %>; | 47 ssl_certificate_key <%= @private_key %>; |
| 48 ssl_dhparam /etc/nginx/dhparam.pem; | 48 ssl_dhparam /etc/nginx/dhparam.pem; |
| 49 | 49 |
| 50 add_header Strict-Transport-Security max-age=31536000; | 50 add_header Strict-Transport-Security max-age=31536000; |
| 51 <% else %> | 51 <% else %> |
| 52 server | 52 server |
| 53 { | 53 { |
| 54 server_name <% server_name[domain, alt_names] %>; | 54 server_name <% server_name[@domain, @alt_names] %>; |
| 55 | 55 |
| 56 <% if is_default %> | 56 <% if @is_default %> |
| 57 listen 80 default_server; | 57 listen 80 default_server; |
| 58 listen [::]:80 default_server; | 58 listen [::]:80 default_server; |
| 59 <% else %> | 59 <% else %> |
| 60 listen 80; | 60 listen 80; |
| 61 listen [::]:80; | 61 listen [::]:80; |
| 62 <% end %> | 62 <% end %> |
| 63 <% end %> | 63 <% end %> |
| 64 | 64 |
| 65 access_log /var/log/nginx/<%= log %> <%= log_format %>; | 65 access_log /var/log/nginx/<%= @log %> <%= @log_format %>; |
| 66 | 66 |
| 67 # redirect server error pages to the static page /50x.html | 67 # redirect server error pages to the static page /50x.html |
| 68 # | 68 # |
| 69 error_page 500 502 503 504 /50x.html; | 69 error_page 500 502 503 504 /50x.html; |
| 70 location = /50x.html | 70 location = /50x.html |
| 71 { | 71 { |
| 72 root /usr/share/nginx/html; | 72 root /usr/share/nginx/html; |
| 73 } | 73 } |
| 74 | 74 |
| 75 # https://issues.adblockplus.org/ticket/4894 | 75 # https://issues.adblockplus.org/ticket/4894 |
| 76 location /easylistchina+easylist.txt | 76 location /easylistchina+easylist.txt |
| 77 { | 77 { |
| 78 if ($http_user_agent = "") | 78 if ($http_user_agent = "") |
| 79 { | 79 { |
| 80 return 400; | 80 return 400; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 if ($http_host ~ "^(.+)\.$") | 84 if ($http_host ~ "^(.+)\.$") |
| 85 { | 85 { |
| 86 set $canonical_host $1; | 86 set $canonical_host $1; |
| 87 rewrite ^(.*) $scheme://$canonical_host$1 permanent; | 87 rewrite ^(.*) $scheme://$canonical_host$1 permanent; |
| 88 } | 88 } |
| 89 | 89 |
| 90 <% if @content %> | 90 <% if @content %> |
| 91 <%= content %> | 91 <%= @content %> |
| 92 <% end %> | 92 <% end %> |
| 93 | 93 |
| 94 <% if @source %> | 94 <% if @source %> |
| 95 <% include_file[source] %> | 95 <% include_file[@source] %> |
| 96 <% end %> | 96 <% end %> |
| 97 } | 97 } |
| OLD | NEW |