diff --git a/defaults/main.yml b/defaults/main.yml index a83f762..ddb493d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -86,7 +86,9 @@ nginx_log_format: |- '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"' -nginx_realIP_Proxy: +nginx_realIP_Proxy: nginx_logrotate_number: 4 ## weekly,dailly.. nginx_logrotate_period: "weekly" +nginx_ssl_cert_name: +nginx_conf_path: /etc/nginx/conf.d/ diff --git a/tasks/main.yml b/tasks/main.yml index 3ac10d1..5edbe54 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -55,12 +55,18 @@ - name: Apply logrotate file template: - dest: /etc/logrotate.d/nginx - src: logrotate/nginx.j2 + dest: /etc/logrotate.d/nginx + src: logrotate/nginx.j2 + +- name: create nginx config ssl file + template: + mode: 0750 + dest: "{{ nginx_conf_path }}/{{ nginx_ssl_cert_name }}.ssl" + src: nginx_ssl_config.j2 + when: nginx_ssl_cert_name is defined - name: Ensure nginx is started and enabled to start at boot. service: name: nginx state: started enabled: yes - diff --git a/templates/nginx_ssl_config.j2 b/templates/nginx_ssl_config.j2 new file mode 100644 index 0000000..775bba0 --- /dev/null +++ b/templates/nginx_ssl_config.j2 @@ -0,0 +1,10 @@ +ssl_certificate /etc/ssl/{{ nginx_ssl_cert_name }}/fullchain.pem; +ssl_certificate_key /etc/ssl/{{ nginx_ssl_cert_name }}/privkey.pem; +ssl_session_cache shared:le_nginx_SSL:10m; +ssl_session_timeout 1440m; +ssl_session_tickets off; +ssl_protocols TLSv1.2 TLSv1.3; +ssl_prefer_server_ciphers off; +ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"; +ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; +add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;