Remove Nginx
This commit is contained in:
parent
ec68c743dc
commit
51132fd193
14 changed files with 2 additions and 306 deletions
|
@ -6,10 +6,5 @@ common__certbot__run: true
|
|||
common__certbot__email: 'user@example.com'
|
||||
common__certbot__cert_name: 'example.com'
|
||||
common__certbot__cert_domains: ['example.com', 'www.example.com']
|
||||
common__certbot__post_hook: 'systemctl is-active nginx.service || systemctl start nginx.service'
|
||||
common__certbot__pre_hook: 'systemctl is-active nginx.service && systemctl stop nginx.service || true'
|
||||
|
||||
common__nginx__state: null
|
||||
common__nginx__remove_default: true
|
||||
common__nginx__upstreams: []
|
||||
common__nginx__sites: []
|
||||
common__certbot__post_hook: null
|
||||
common__certbot__pre_hook: null
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
access_log syslog:server=unix:/dev/log,facility=local7,severity=info,tag=nginx;
|
||||
error_log syslog:server=unix:/dev/log,facility=local7,severity=error,tag=nginx;
|
|
@ -4,9 +4,3 @@
|
|||
daemon_reload: true
|
||||
name: sshd
|
||||
state: restarted
|
||||
|
||||
- name: common | Restart Nginx
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
name: nginx
|
||||
state: restarted
|
||||
|
|
|
@ -17,17 +17,3 @@
|
|||
- include_tasks: certbot/install.yml
|
||||
when: common__certbot__state == 'install'
|
||||
- meta: flush_handlers
|
||||
|
||||
- fail:
|
||||
msg: 'Invalid `common__nginx__state`: {{ common__nginx__state }}'
|
||||
when: (common__nginx__state != None) and
|
||||
(common__nginx__state != 'purge') and
|
||||
(common__nginx__state != 'remove') and
|
||||
(common__nginx__state != 'install')
|
||||
- include_tasks: nginx/purge.yml
|
||||
when: common__nginx__state == 'purge'
|
||||
- include_tasks: nginx/remove.yml
|
||||
when: common__nginx__state == 'remove'
|
||||
- include_tasks: nginx/install.yml
|
||||
when: common__nginx__state == 'install'
|
||||
- meta: flush_handlers
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
---
|
||||
- name: Install Nginx
|
||||
apt:
|
||||
name: nginx
|
||||
|
||||
- name: Create directories for Nginx configuration
|
||||
file:
|
||||
state: directory
|
||||
path: '{{ item }}'
|
||||
mode: 'u=rwx,go=rx'
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- '{{ common__nginx__conf_dir }}'
|
||||
- '{{ common__nginx__confd_dir }}'
|
||||
- '{{ common__nginx__available_dir }}'
|
||||
- '{{ common__nginx__enabled_dir }}'
|
||||
- '{{ common__nginx__snippets_dir }}'
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Disable Nginx access log
|
||||
lineinfile:
|
||||
path: '{{ common__nginx__conf_dir }}/nginx.conf'
|
||||
regexp: '^(\s*)#?\s*access_log\s+\S+\s*;\s*$'
|
||||
line: '\1#access_log /var/log/nginx/access.log;'
|
||||
backrefs: true
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Disable Nginx error log
|
||||
lineinfile:
|
||||
path: '{{ common__nginx__conf_dir }}/nginx.conf'
|
||||
regexp: '^(\s*)#?\s*error_log\s+\S+\s*;\s*$'
|
||||
line: '\1#error_log /var/log/nginx/error.log;'
|
||||
backrefs: true
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Install Nginx log config
|
||||
copy:
|
||||
src: 'files/nginx/syslog.conf'
|
||||
dest: '{{ common__nginx__confd_dir }}/syslog.conf'
|
||||
mode: 'u=rw,go=r'
|
||||
owner: root
|
||||
group: root
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Remove Nginx default site
|
||||
file:
|
||||
state: absent
|
||||
path: '{{ common__nginx__enabled_dir }}/default'
|
||||
when: common__nginx__remove_default|bool
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Add Nginx upstreams
|
||||
template:
|
||||
src: 'templates/nginx/upstream.conf'
|
||||
dest: '{{ common__nginx__confd_dir }}/upstream-{{ item.name }}.conf'
|
||||
mode: 'u=rw,go=r'
|
||||
owner: root
|
||||
group: root
|
||||
with_items: '{{ common__nginx__upstreams }}'
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Add Nginx sites
|
||||
template:
|
||||
src: 'templates/nginx/{{ item.type }}.conf'
|
||||
dest: '{{ common__nginx__available_dir }}/{{ item.domain }}.conf'
|
||||
mode: 'u=rw,go=r'
|
||||
owner: root
|
||||
group: root
|
||||
with_items: '{{ common__nginx__sites }}'
|
||||
notify: common | Restart Nginx
|
||||
|
||||
- name: Enable Nginx sites
|
||||
file:
|
||||
state: link
|
||||
src: '{{ common__nginx__available_dir }}/{{ item.domain }}.conf'
|
||||
dest: '{{ common__nginx__enabled_dir }}/{{ item.domain }}.conf'
|
||||
owner: root
|
||||
group: root
|
||||
with_items: '{{ common__nginx__sites }}'
|
||||
notify: common | Restart Nginx
|
|
@ -1,14 +0,0 @@
|
|||
---
|
||||
- name: Purge Nginx
|
||||
apt:
|
||||
state: absent
|
||||
purge: true
|
||||
name:
|
||||
- nginx
|
||||
- nginx-common
|
||||
- nginx-core
|
||||
|
||||
- name: Delete Nginx configuration
|
||||
file:
|
||||
state: absent
|
||||
path: '{{ common__nginx__conf_dir }}'
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
- name: Uninstall Nginx
|
||||
apt:
|
||||
state: absent
|
||||
purge: false
|
||||
name:
|
||||
- nginx
|
||||
- nginx-common
|
||||
- nginx-core
|
|
@ -1,27 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
ssl_certificate {{ item.cert }};
|
||||
ssl_certificate_key {{ item.key }};
|
||||
|
||||
include {{ item.ssl_conf }};
|
||||
|
||||
root {{ item.root }};
|
||||
|
||||
try_files $uri $uri/ =404;
|
||||
|
||||
charset utf-8;
|
||||
autoindex on;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
ssl_certificate {{ item.cert }};
|
||||
ssl_certificate_key {{ item.key }};
|
||||
|
||||
include {{ item.ssl_conf }};
|
||||
|
||||
root {{ item.root }};
|
||||
|
||||
try_files $uri/index.html $uri @origin;
|
||||
|
||||
location @origin {
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_http_version 1.1;
|
||||
proxy_redirect off;
|
||||
|
||||
{% if item.external %}
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header HOST $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
{% else %}
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header HOST $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
{% endif %}
|
||||
|
||||
proxy_pass http://{{ item.upstream }};
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /500.html;
|
||||
client_max_body_size 4G;
|
||||
keepalive_timeout 10;
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
ssl_certificate {{ item.cert }};
|
||||
ssl_certificate_key {{ item.key }};
|
||||
|
||||
include {{ item.ssl_conf }};
|
||||
|
||||
ssl_verify_client optional;
|
||||
ssl_client_certificate {{ item.clnt_ca }};
|
||||
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_http_version 1.1;
|
||||
proxy_redirect off;
|
||||
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header HOST $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
location / {
|
||||
recursive_error_pages on;
|
||||
|
||||
error_page 418 = @no_crt;
|
||||
error_page 419 = @with_crt;
|
||||
|
||||
if ($ssl_client_verify != SUCCESS) {
|
||||
return 418;
|
||||
}
|
||||
|
||||
if ($ssl_client_verify = SUCCESS) {
|
||||
return 419;
|
||||
}
|
||||
}
|
||||
|
||||
location @no_crt {
|
||||
proxy_pass https://{{ item.no_crt }};
|
||||
}
|
||||
|
||||
location @with_crt {
|
||||
proxy_pass https://{{ item.with_crt }};
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{{ item.content }}
|
|
@ -1,22 +0,0 @@
|
|||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
|
||||
server_name {{ item.domain }};
|
||||
|
||||
ssl_certificate {{ item.cert }};
|
||||
ssl_certificate_key {{ item.key }};
|
||||
|
||||
include {{ item.ssl_conf }};
|
||||
|
||||
return 301 https://{{ item.redir_to }}$request_uri;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
upstream {{ item.name }} {
|
||||
{% for server in item.servers %}
|
||||
server {{ server }};
|
||||
{% endfor %}
|
||||
}
|
|
@ -6,12 +6,6 @@ common__certbot__conf_nginx: '{{ common__certbot__conf_dir }}/options-ssl-nginx.
|
|||
common__certbot__archive_dir: '{{ common__certbot__conf_dir }}/archive'
|
||||
common__certbot__live_dir: '{{ common__certbot__conf_dir }}/live'
|
||||
|
||||
common__nginx__conf_dir: '/etc/nginx'
|
||||
common__nginx__confd_dir: '{{ common__nginx__conf_dir }}/conf.d'
|
||||
common__nginx__available_dir: '{{ common__nginx__conf_dir }}/sites-available'
|
||||
common__nginx__enabled_dir: '{{ common__nginx__conf_dir }}/sites-enabled'
|
||||
common__nginx__snippets_dir: '{{ common__nginx__conf_dir }}/snippets'
|
||||
|
||||
common__certbot__nginx_ssl_ciphers:
|
||||
- 'ECDHE-ECDSA-AES128-GCM-SHA256'
|
||||
- 'ECDHE-RSA-AES128-GCM-SHA256'
|
||||
|
|
Loading…
Add table
Reference in a new issue