mirror of
https://github.com/dev-sec/ansible-nginx-hardening.git
synced 2024-11-22 23:51:57 +01:00
use restart instead of reload, fix syntax
This commit is contained in:
parent
e2113ccbf1
commit
3efd10d119
@ -1,2 +1,4 @@
|
|||||||
- name: reload nginx
|
- name: restart nginx
|
||||||
service: name={{ nginx_service_name }} state=reloaded
|
service:
|
||||||
|
name: "nginx"
|
||||||
|
state: restarted
|
||||||
|
@ -10,58 +10,71 @@
|
|||||||
- name: create additional configuration
|
- name: create additional configuration
|
||||||
template:
|
template:
|
||||||
src: "hardening.conf.j2"
|
src: "hardening.conf.j2"
|
||||||
dest: "{{ nginx_config_conf_dir }}/90.hardening.conf"
|
dest: "/etc/nginx/conf.d/90.hardening.conf"
|
||||||
owner: "root"
|
owner: "root"
|
||||||
group: "root"
|
group: "root"
|
||||||
notify: reload nginx
|
notify: restart nginx
|
||||||
|
|
||||||
- name: change configuration in main nginx.conf
|
- name: change configuration in main nginx.conf
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "/etc/nginx/nginx.conf"
|
dest: "/etc/nginx/nginx.conf"
|
||||||
regexp: "^\\s*server_tokens"
|
regexp: '^\s*server_tokens'
|
||||||
line: "server_tokens {{ nginx_server_tokens }};"
|
line: " server_tokens {{ nginx_server_tokens }};"
|
||||||
insertafter: "http {"
|
insertafter: "http {"
|
||||||
notify: reload nginx
|
notify: restart nginx
|
||||||
|
|
||||||
- name: change ssl_protocols in main nginx.conf
|
- name: change ssl_protocols in main nginx.conf
|
||||||
lineinfile: dest="/etc/nginx/nginx.conf" regexp="^\s*ssl_protocols" line="ssl_protocols {{nginx_ssl_protocols}};" insertafter="http {"
|
lineinfile:
|
||||||
notify: reload nginx
|
dest: "/etc/nginx/nginx.conf"
|
||||||
|
regexp: '^\s*ssl_protocols'
|
||||||
|
line: " ssl_protocols {{nginx_ssl_protocols}};"
|
||||||
|
insertafter: "http {"
|
||||||
|
notify: restart nginx
|
||||||
|
|
||||||
- name: change ssl_prefer_server_ciphers in main nginx.conf
|
- name: change ssl_prefer_server_ciphers in main nginx.conf
|
||||||
lineinfile: dest="/etc/nginx/nginx.conf" regexp="^\s*ssl_prefer_server_ciphers" line="ssl_prefer_server_ciphers {{nginx_ssl_prefer_server_ciphers}};" insertafter="http {"
|
lineinfile:
|
||||||
notify: reload nginx
|
dest: "/etc/nginx/nginx.conf"
|
||||||
|
regexp: '^\s*ssl_prefer_server_ciphers'
|
||||||
|
line: " ssl_prefer_server_ciphers {{nginx_ssl_prefer_server_ciphers}};"
|
||||||
|
insertafter: "http {"
|
||||||
|
notify: restart nginx
|
||||||
|
|
||||||
- name: change client_max_body_size in main nginx.conf
|
- name: change client_max_body_size in main nginx.conf
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "/etc/nginx/nginx.conf"
|
dest: "/etc/nginx/nginx.conf"
|
||||||
regexp: "^\\s*client_max_body_size"
|
regexp: '^\s*client_max_body_size'
|
||||||
line: "client_max_body_size {{ nginx_client_max_body_size }};"
|
line: " client_max_body_size {{ nginx_client_max_body_size }};"
|
||||||
insertafter: "http {"
|
insertafter: "http {"
|
||||||
notify: reload nginx
|
notify: restart nginx
|
||||||
|
|
||||||
- name: change client_body_buffer_size in main nginx.conf
|
- name: change client_body_buffer_size in main nginx.conf
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "/etc/nginx/nginx.conf"
|
dest: "/etc/nginx/nginx.conf"
|
||||||
regexp: "^\\s*client_body_buffer_size"
|
regexp: '^\s*client_body_buffer_size'
|
||||||
line: "client_body_buffer_size {{ nginx_client_body_buffer_size }};"
|
line: " client_body_buffer_size {{ nginx_client_body_buffer_size }};"
|
||||||
insertafter: "http {"
|
insertafter: "http {"
|
||||||
notify: reload nginx
|
notify: restart nginx
|
||||||
|
|
||||||
- name: change keepalive_timeout in main nginx.conf
|
- name: change keepalive_timeout in main nginx.conf
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "/etc/nginx/nginx.conf"
|
dest: "/etc/nginx/nginx.conf"
|
||||||
regexp: "^\\s*keepalive_timeout"
|
regexp: '^\s*keepalive_timeout'
|
||||||
line: "keepalive_timeout {{ nginx_keepalive_timeout }};"
|
line: " keepalive_timeout {{ nginx_keepalive_timeout }};"
|
||||||
insertafter: "http {"
|
insertafter: "http {"
|
||||||
notify: reload nginx
|
notify: restart nginx
|
||||||
|
|
||||||
- name: remove default.conf
|
- name: remove default.conf
|
||||||
file:
|
file:
|
||||||
path: "{{ nginx_default_conf }}"
|
path: "{{ item }}"
|
||||||
state: absent
|
state: absent
|
||||||
when: nginx_remove_default_site
|
when: nginx_remove_default_site
|
||||||
notify: reload nginx
|
notify: restart nginx
|
||||||
|
loop:
|
||||||
|
- "/etc/nginx/conf.d/default.conf"
|
||||||
|
- "/etc/nginx/sites-enabled/default"
|
||||||
|
|
||||||
- name: generate dh group
|
- name: generate dh group
|
||||||
command: openssl dhparam -out {{ nginx_dh_param }} {{ nginx_dh_size }} creates={{ nginx_dh_param }}
|
command: "openssl dhparam -out /etc/nginx/dh{{nginx_dh_size}}.pem {{ nginx_dh_size }}"
|
||||||
notify: reload nginx
|
args:
|
||||||
|
creates: "/etc/nginx/dh{{nginx_dh_size}}.pem"
|
||||||
|
notify: restart nginx
|
||||||
|
Loading…
Reference in New Issue
Block a user