Create a nginx_certbot_site resource to remove duplication
It creates a folder, the nginx vhost for certbot and HTTP redirects, and also runs certbot and recreates the nginx vhost that includes the TLS cert
This commit is contained in:
@@ -1,21 +1,6 @@
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
server {
|
||||
listen 80;
|
||||
server_name <%= @server_name %>;
|
||||
access_log /var/log/nginx/<%= @server_name %>.access.log;
|
||||
error_log /var/log/nginx/<%= @server_name %>.error.log;
|
||||
|
||||
location /.well-known {
|
||||
root <%= @docroot %>;
|
||||
}
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
listen 443 ssl;
|
||||
<% end -%>
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
access_log /var/log/nginx/<%= @server_name %>.access.log;
|
||||
@@ -38,9 +23,8 @@ server {
|
||||
fastcgi_param HTTP_PROXY "";
|
||||
}
|
||||
|
||||
<% if File.exist?(@ssl_cert) && File.exist?(@ssl_key) -%>
|
||||
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains";
|
||||
ssl_certificate <%= @ssl_cert %>;
|
||||
ssl_certificate_key <%= @ssl_key %>;
|
||||
<% end -%>
|
||||
}
|
||||
<% end -%>
|
||||
|
||||
Reference in New Issue
Block a user