Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/nginx/templates/site.erb

Issue 5734493784637440: Issue 245 - Unify SSL configuration for all servers (Closed)
Patch Set: Created April 2, 2014, 2:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/nginx/templates/site.erb
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/nginx/templates/site.erb
@@ -0,0 +1,69 @@
+<% include_file = lambda do |url| %>
+ <% content = Puppet::FileServing::Content.indirection.find(url) %>
+ <% if content %>
+ <%= content.content %>
+ <% else %>
+ <% raise StandardError, "Failed to resolve source URL #{url}" %>
+ <% end %>
+<% end %>
+
+<% server_name = lambda do |domain, alt_names| %><%= domain %><% @alt_names.each do |name| %>, <%= name %><% end %><% end %>
+
+<% if global_config %>
+ <%= @global_config %>
+<% end %>
+
+<% if @certificate and @private_key %>
+ server {
+ server_name <% server_name[domain, alt_names] %>;
+
+ <% if is_default %>
+ listen 80 default_server;
+ listen [::]:80 default_server;
+ <% else %>
+ listen 80;
+ listen [::]:80;
+ <% end %>
+
+ location / {
+ rewrite (.*) https://$host$1 permanent;
+ }
+ }
+ server {
+ server_name <% server_name[domain, alt_names] %>;
+
+ <% if is_default %>
+ listen 443 ssl spdy default_server;
+ listen [::]:443 ssl spdy default_server;
+ <% else %>
+ listen 443 ssl spdy;
+ listen [::]:443 ssl spdy;
+ <% end %>
+
+ ssl_certificate <%= certificate %>;
+ ssl_certificate_key <%= private_key %>;
+
+ add_header Strict-Transport-Security max-age=31536000;
+<% else %>
+ server {
+ server_name <% server_name[domain, alt_names] %>;
+
+ <% if is_default %>
+ listen 80 default_server;
+ listen [::]:80 default_server;
+ <% else %>
+ listen 80;
+ listen [::]:80;
+ <% end %>
+<% end %>
+
+access_log /var/log/nginx/<%= log %> main;
+
+<% if @content %>
+ <%= content %>
+<% end %>
+
+<% if @source %>
+ <% include_file[source] %>
+<% end %>
+}

Powered by Google App Engine
This is Rietveld