Add the ufw firewall
This commit is contained in:
parent
d7838563a1
commit
45465ad26b
23
roles/base/tasks/firewall.yml
Normal file
23
roles/base/tasks/firewall.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
- name: Install the Uncomplicated Firewall
|
||||||
|
apt:
|
||||||
|
name: ufw
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Deny incoming traffic by default
|
||||||
|
ufw:
|
||||||
|
default: deny
|
||||||
|
direction: incoming
|
||||||
|
|
||||||
|
- name: Allow outgoing traffic by default
|
||||||
|
ufw:
|
||||||
|
default: allow
|
||||||
|
direction: outgoing
|
||||||
|
|
||||||
|
- name: Allow OpenSSH with rate limiting
|
||||||
|
ufw:
|
||||||
|
name: ssh
|
||||||
|
rule: limit
|
||||||
|
|
||||||
|
- name: Enable firewall
|
||||||
|
ufw:
|
||||||
|
state: enabled
|
@ -4,6 +4,9 @@
|
|||||||
- import_tasks: system.yml
|
- import_tasks: system.yml
|
||||||
tags: system
|
tags: system
|
||||||
|
|
||||||
|
- import_tasks: firewall.yml
|
||||||
|
tags: firewall
|
||||||
|
|
||||||
- import_tasks: network.yml
|
- import_tasks: network.yml
|
||||||
tags: network
|
tags: network
|
||||||
when: manage_network
|
when: manage_network
|
||||||
|
@ -32,3 +32,10 @@
|
|||||||
name: postgresql
|
name: postgresql
|
||||||
state: restarted
|
state: restarted
|
||||||
when: postgresql_config.changed
|
when: postgresql_config.changed
|
||||||
|
|
||||||
|
- name: Allow database connections from Docker
|
||||||
|
ufw:
|
||||||
|
rule: allow
|
||||||
|
port: "5432"
|
||||||
|
proto: tcp
|
||||||
|
src: "172.16.0.0/12"
|
||||||
|
@ -84,3 +84,12 @@
|
|||||||
loop: "{{ proxy.dns_cloudflare.wildcard_domains }}"
|
loop: "{{ proxy.dns_cloudflare.wildcard_domains }}"
|
||||||
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
|
when: proxy.production is defined and proxy.production and proxy.dns_cloudflare is defined
|
||||||
notify: reload_nginx
|
notify: reload_nginx
|
||||||
|
|
||||||
|
- name: Add HTTP and HTTPS firewall rule
|
||||||
|
ufw:
|
||||||
|
rule: allow
|
||||||
|
port: "{{ item }}"
|
||||||
|
proto: tcp
|
||||||
|
loop:
|
||||||
|
- "80"
|
||||||
|
- "443"
|
||||||
|
Loading…
Reference in New Issue
Block a user