proxmox: public web (80/443 -> Caddy), Forgejo SSH 2222, hairpin NAT
This commit is contained in:
parent
54303eb268
commit
09fbb9d2fb
1 changed files with 36 additions and 0 deletions
|
|
@ -414,6 +414,15 @@
|
||||||
hosts: hypervisors
|
hosts: hypervisors
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
tags: [proxmox]
|
tags: [proxmox]
|
||||||
|
vars:
|
||||||
|
# Written exactly as `iptables -t nat -S` prints them, minus "-A ".
|
||||||
|
utils_public_nat_rules:
|
||||||
|
- PREROUTING -i vmbr0 -p tcp -m tcp --dport 443 -j DNAT --to-destination 10.0.0.10:443
|
||||||
|
- PREROUTING -i vmbr0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.0.10:80
|
||||||
|
- PREROUTING -i vmbr0 -p tcp -m tcp --dport 2222 -j DNAT --to-destination 10.0.0.14:2222
|
||||||
|
- PREROUTING -d 138.195.128.200/32 -i vmbr1 -p tcp -m multiport --dports 80,443 -j DNAT --to-destination 10.0.0.10
|
||||||
|
- PREROUTING -d 138.195.128.200/32 -i vmbr1 -p tcp -m tcp --dport 2222 -j DNAT --to-destination 10.0.0.14:2222
|
||||||
|
- POSTROUTING -s 10.0.0.0/24 -m conntrack --ctstate DNAT --ctorigdst 138.195.128.200 -j MASQUERADE
|
||||||
tasks:
|
tasks:
|
||||||
# The file was fully commented out, so the host got no PVE updates at all.
|
# The file was fully commented out, so the host got no PVE updates at all.
|
||||||
- name: Enable the pve-no-subscription repository
|
- name: Enable the pve-no-subscription repository
|
||||||
|
|
@ -461,6 +470,33 @@
|
||||||
line: -A PREROUTING -i vmbr0 -p udp -m udp --dport 443 -j DNAT --to-destination 10.0.0.250:51820
|
line: -A PREROUTING -i vmbr0 -p udp -m udp --dport 443 -j DNAT --to-destination 10.0.0.250:51820
|
||||||
insertafter: ^-A PREROUTING -i vmbr0 -p udp -m udp --dport 51820 -j DNAT
|
insertafter: ^-A PREROUTING -i vmbr0 -p udp -m udp --dport 51820 -j DNAT
|
||||||
|
|
||||||
|
# Public web (2026-10-30): tcp 80/443 -> Caddy, 2222 -> Forgejo SSH. Caddy
|
||||||
|
# aborts every site not meant for the internet (wg_only snippet), so only
|
||||||
|
# vault, forgejo, md, pad, pterodactyl and wings answer from outside.
|
||||||
|
# The vmbr1 rules are hairpin NAT: guests that resolve a public name reach
|
||||||
|
# Caddy too, and show up as 10.0.0.1 (allowed by wg_only).
|
||||||
|
- name: Public web and Forgejo SSH (live)
|
||||||
|
ansible.builtin.command: iptables -t nat -C {{ item }}
|
||||||
|
register: utils_public_nat
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
loop: "{{ utils_public_nat_rules }}"
|
||||||
|
|
||||||
|
- name: Public web and Forgejo SSH (add missing live rules)
|
||||||
|
ansible.builtin.command: iptables -t nat -A {{ item.item }}
|
||||||
|
loop: "{{ utils_public_nat.results | selectattr('rc', '!=', 0) | list }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.item }}"
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Public web and Forgejo SSH (rules.v4)
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/iptables/rules.v4
|
||||||
|
line: -A {{ item }}
|
||||||
|
insertbefore: ^-A POSTROUTING -s 10.0.0.0/24 -o vmbr0 -j MASQUERADE
|
||||||
|
firstmatch: true
|
||||||
|
loop: "{{ utils_public_nat_rules }}"
|
||||||
|
|
||||||
- name: WireGuard hub
|
- name: WireGuard hub
|
||||||
hosts: wireguard
|
hosts: wireguard
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue