Compare commits
No commits in common. "fa32cab25b1e896913309c736f957be84fe45ec6" and "8257b0b4a7f06c9731b50183abcb3b920e08cbc4" have entirely different histories.
fa32cab25b
...
8257b0b4a7
8 changed files with 135 additions and 35 deletions
|
@ -13,3 +13,8 @@
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
- gnupg
|
- gnupg
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure unattended-upgrades is runing
|
||||||
|
service:
|
||||||
|
name: unattended-upgrades
|
||||||
|
enabled: true
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
---
|
|
||||||
- name: Add apt key for crowdsec
|
|
||||||
apt_key:
|
|
||||||
url: https://packagecloud.io/crowdsec/crowdsec/gpgkey
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Add crowdsec repository into sources list
|
|
||||||
apt_repository:
|
|
||||||
repo: deb https://packagecloud.io/crowdsec/crowdsec/debian bullseye main
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Install crowdsec packages
|
|
||||||
apt:
|
|
||||||
name:
|
|
||||||
- crowdsec
|
|
||||||
state: present
|
|
||||||
# sudo cscli lapi register -u http://192.168.1.10:8081 --machine npm-crowdsec
|
|
||||||
# accept on unraid crowdsec
|
|
||||||
# sudo systemctl restart crowdsec
|
|
||||||
# update /etc/crowdsec/acquis.yml
|
|
||||||
# filenames:
|
|
||||||
# - ~/data/logs/*.log
|
|
||||||
# labels:
|
|
||||||
# type: nginx-proxy-manager#
|
|
||||||
# cscli collections install crowdsecurity/nginx-proxy-manager
|
|
||||||
#
|
|
||||||
# /etc/crowdsec/config.yml
|
|
||||||
# * listen_uri: 127.0.0.1:8080 # to 8081
|
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
- name: Add apt key for docker
|
- name: Add apt key for docker
|
||||||
apt_key:
|
apt_key:
|
||||||
url: https://download.docker.com/linux/debian/gpg
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add docker repository into sources list
|
- name: Add docker repository into sources list
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo: deb https://download.docker.com/linux/debian bullseye stable
|
repo: deb https://download.docker.com/linux/ubuntu jammy stable
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install docker packages
|
- name: Install docker packages
|
||||||
|
@ -15,6 +15,5 @@
|
||||||
- docker-ce
|
- docker-ce
|
||||||
- docker-ce-cli
|
- docker-ce-cli
|
||||||
- containerd.io
|
- containerd.io
|
||||||
- docker-buildx-plugin
|
|
||||||
- docker-compose-plugin
|
- docker-compose-plugin
|
||||||
state: present
|
state: present
|
||||||
|
|
3
roles/firewall/handlers/main.yml
Normal file
3
roles/firewall/handlers/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
- name: Persist iptables
|
||||||
|
shell:
|
||||||
|
cmd: iptables-save > /etc/iptables/rules.v4
|
97
roles/firewall/tasks/main.yml
Normal file
97
roles/firewall/tasks/main.yml
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
---
|
||||||
|
- name: Install iptables packages
|
||||||
|
apt:
|
||||||
|
name: iptables-persistent
|
||||||
|
state: present
|
||||||
|
|
||||||
|
# TURN IT OFF
|
||||||
|
- name: Turn iptables off for now
|
||||||
|
service:
|
||||||
|
name: iptables
|
||||||
|
state: stopped
|
||||||
|
enabled: no
|
||||||
|
|
||||||
|
- name: Allow all loopback traffic
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
in_interface: lo
|
||||||
|
jump: ACCEPT
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow port ping traffic
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
jump: ACCEPT
|
||||||
|
protocol: icmp
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow related and established connections
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
ctstate: ESTABLISHED,RELATED
|
||||||
|
jump: ACCEPT
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow SSH
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
destination_port: 22
|
||||||
|
jump: ACCEPT
|
||||||
|
protocol: tcp
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow web
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
protocol: tcp
|
||||||
|
destination_port: 80
|
||||||
|
jump: ACCEPT
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow admin web (nginx proxy)
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
protocol: tcp
|
||||||
|
destination_port: 81
|
||||||
|
jump: ACCEPT
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow dns
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
protocol: tcp
|
||||||
|
destination_port: 53
|
||||||
|
jump: ACCEPT
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow dns (udp)
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
protocol: udp
|
||||||
|
destination_port: 53
|
||||||
|
jump: ACCEPT
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Allow related and established connections
|
||||||
|
ansible.builtin.iptables:
|
||||||
|
chain: INPUT
|
||||||
|
ctstate: ESTABLISHED,RELATED
|
||||||
|
jump: ACCEPT
|
||||||
|
|
||||||
|
- name: Set the policy for the INPUT chain to DROP
|
||||||
|
iptables:
|
||||||
|
chain: INPUT
|
||||||
|
policy: DROP
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Set the policy for the FORWARD chain to DROP
|
||||||
|
iptables:
|
||||||
|
chain: FORWARD
|
||||||
|
policy: DROP
|
||||||
|
notify: Persist iptables
|
||||||
|
|
||||||
|
- name: Set the policy for the OUTPUT chain to ACCEPT
|
||||||
|
iptables:
|
||||||
|
chain: OUTPUT
|
||||||
|
policy: ACCEPT
|
||||||
|
notify: Persist iptables
|
|
@ -1,7 +1,7 @@
|
||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: jc21/nginx-proxy-manager:latest
|
image: jc21/nginx-proxy-manager:2.9.22
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 80:80 # Public HTTP Port
|
- 80:80 # Public HTTP Port
|
||||||
|
@ -10,5 +10,8 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
- ./letsencrypt:/etc/letsencrypt
|
- ./letsencrypt:/etc/letsencrypt
|
||||||
|
- ./default.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
# hack to avoid sed on default.conf
|
||||||
|
- /dev/null:/etc/s6-overlay/s6-rc.d/prepare/50-ipv6.sh
|
||||||
environment:
|
environment:
|
||||||
- AWS_CONFIG_FILE=/etc/letsencrypt/credentials/credentials-6
|
- AWS_CONFIG_FILE=/etc/letsencrypt/credentials/credentials-6
|
||||||
|
|
|
@ -9,6 +9,28 @@
|
||||||
with_items:
|
with_items:
|
||||||
- regexp: '^PasswordAuthentication'
|
- regexp: '^PasswordAuthentication'
|
||||||
line: 'PasswordAuthentication no'
|
line: 'PasswordAuthentication no'
|
||||||
- regexp: '^#PermitRootLogin'
|
- regexp: '^PermitRootLogin'
|
||||||
line: 'PermitRootLogin no'
|
line: 'PermitRootLogin no'
|
||||||
notify: Restart ssh
|
notify: Restart ssh
|
||||||
|
|
||||||
|
- name: Install fail2ban
|
||||||
|
apt:
|
||||||
|
name: fail2ban
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Configure fail2ban
|
||||||
|
blockinfile:
|
||||||
|
path: /etc/fail2ban/jail.local
|
||||||
|
create: yes
|
||||||
|
mode: 0644
|
||||||
|
block: |
|
||||||
|
[sshd]
|
||||||
|
enabled = true
|
||||||
|
filter = sshd
|
||||||
|
# notify: Restart fail2ban
|
||||||
|
|
||||||
|
- name: Turn fail2ban off for now
|
||||||
|
service:
|
||||||
|
name: fail2ban
|
||||||
|
enabled: false
|
||||||
|
state: stopped
|
||||||
|
|
3
site.yml
3
site.yml
|
@ -10,6 +10,7 @@
|
||||||
- role: instance
|
- role: instance
|
||||||
tags: instance
|
tags: instance
|
||||||
- role: apt
|
- role: apt
|
||||||
|
- role: firewall
|
||||||
- role: administrators
|
- role: administrators
|
||||||
- role: ssh
|
- role: ssh
|
||||||
- hosts: dns
|
- hosts: dns
|
||||||
|
@ -21,7 +22,5 @@
|
||||||
become: yes
|
become: yes
|
||||||
roles:
|
roles:
|
||||||
- role: docker
|
- role: docker
|
||||||
- role: crowdsec
|
|
||||||
tags: cs
|
|
||||||
- role: nginx-proxy-manager
|
- role: nginx-proxy-manager
|
||||||
tags: npm
|
tags: npm
|
||||||
|
|
Loading…
Add table
Reference in a new issue