unifi: Switch from nginx to Caddy

Mostly for built-in ACME support.
unifi-restore
Dustin 2025-03-16 16:39:42 -05:00
parent fbbe86c651
commit db5d1fb91a
6 changed files with 27 additions and 28 deletions

View File

@ -0,0 +1 @@
unifi_server_name: '{{ ansible_fqdn }}'

View File

@ -1,4 +1,8 @@
nginx_redirect_http_https: true
unifi_server_name: unifi.pyrocufflink.blue
unifi_caddy_acme:
email: unifi@pyrocufflink.net
url: https://ca.pyrocufflink.blue/acme/acme/directory
unifi_exporter_site: Pyrocufflink
unifi_exporter_username: prometheus
unifi_exporter_password: !vault |

View File

@ -30,23 +30,12 @@
tags:
- firewalld
- name: ensure nginx is configured to proxy for unifi
- name: ensure caddy is configured to proxy for unifi
template:
src: unifi.nginx.conf.j2
dest: /etc/nginx/default.d/unifi.conf
mode: u=rw,go=r
src: unifi.caddyfile.j2
dest: /etc/caddy/Caddyfile.d/unifi.caddyfile
owner: root
group: root
mode: u=rw,go=r
notify:
- reload nginx
tags:
- nginx
- name: ensure selinux allows nginx to proxy for unifi
seboolean:
name: httpd_can_network_connect
persistent: true
state: true
tags:
- nginx
- selinux
- reload caddy

View File

@ -0,0 +1,13 @@
{{ unifi_server_name }} {
reverse_proxy localhost:8443 {
transport http {
tls_insecure_skip_verify
}
}
{% if unifi_caddy_acme|d %}
tls {{ unifi_caddy_acme.email }} {
ca {{ unifi_caddy_acme.url }}
}
{% endif %}
}

View File

@ -1,9 +0,0 @@
location / {
proxy_pass https://127.0.0.1:8443/;
proxy_ssl_verify off;
client_max_body_size 50m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

View File

@ -1,5 +1,6 @@
- hosts: unifi
roles:
- role: nginx
tags: nginx
- role: caddy
tags: caddy
- role: unifi
tags: unifi