infra/roles/vaultwarden/templates/01-vaultwarden.j2

63 lines
1.9 KiB
Django/Jinja

{% for item in vw_vaults -%}
upstream {{ item.container_name }} {
zone vaultwarden-default 64k;
server {{ bridgewithdns[item.container_name] }}:80;
keepalive 2;
}
server {
listen 443 ssl http2;
{% if inventory_hostname in wg_clients -%}
listen {{ wg_clients[inventory_hostname].ip }}:443 ssl http2;
{% endif -%}
server_name {{ vaultwarden_url }};
include listen-proxy-protocol.conf;
include /etc/nginx/authelia_internal.conf;
include /etc/nginx/sudo-known.conf;
client_max_body_size 525M;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://{{ item.container_name }};
}
# block to include authelia auth
location /admin {
include /etc/nginx/require_auth.conf;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location /admin/ldap {
proxy_pass http://127.0.0.1:{{ vaultwarden_ldap_port_http }}/;
}
proxy_pass http://{{ item.container_name }};
}
access_log /var/log/nginx/access_{{ vaultwarden_url }}.log main;
error_log /var/log/nginx/error_{{ vaultwarden_url }}.log warn;
ssl_session_timeout 5m;
ssl_certificate /usr/local/etc/certs/{{ vaultwarden_url }}/fullchain.pem;
ssl_certificate_key /usr/local/etc/certs/{{ vaultwarden_url }}/privkey.pem;
fastcgi_hide_header X-Powered-By;
}
{% endfor %}