81 lines
2.4 KiB
Django/Jinja
81 lines
2.4 KiB
Django/Jinja
map $authelia_user $paperless_upstream {
|
|
ben {{ bridgewithdns['paperless-ngx-webserver'] }}:8000;
|
|
#default localhost:8000;
|
|
}
|
|
|
|
# cant use variables in the regex of a map
|
|
map $uri $paperless_uri {
|
|
'/$authelia_user' '/$authelia_user/';
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl http2;
|
|
{% if inventory_hostname in wg_clients -%}
|
|
listen {{ wg_clients[inventory_hostname].ip }}:443 ssl http2;
|
|
{% endif -%}
|
|
|
|
root /var/www/{{ paperless_url }};
|
|
server_name {{ paperless_url }};
|
|
|
|
include listen-proxy-protocol.conf;
|
|
include /etc/nginx/authelia_internal.conf;
|
|
include /etc/nginx/sudo-known.conf;
|
|
|
|
resolver {{ pihole_dns }} ipv6=off;
|
|
|
|
# set_real_ip_from 10.0.0.0/8;
|
|
# set_real_ip_from 172.16.0.0/12;
|
|
# set_real_ip_from 192.168.0.0/16;
|
|
# set_real_ip_from fc00::/7;
|
|
# real_ip_header X-Forwarded-For;
|
|
# real_ip_recursive on;
|
|
|
|
|
|
include /etc/nginx/require_auth.conf;
|
|
if ($paperless_uri)
|
|
{
|
|
rewrite ^/(\w+)$ $1/ last;
|
|
}
|
|
|
|
location / {
|
|
include /etc/nginx/require_auth_proxy.conf;
|
|
|
|
# both work!
|
|
set $paperless_user $authelia_user;
|
|
#set $paperless_user $1;
|
|
|
|
# this also works! (but not if you use return)
|
|
#add_header "paperless-authelia-user" $authelia_user always;
|
|
|
|
set $paperless_user $authelia_user;
|
|
add_header "paperless-user" $authelia_user always;
|
|
add_header "paperless-uri" $uri always;
|
|
add_header "paperless-proxy" "true" always;
|
|
add_header "paperless-location-root" "true" always;
|
|
add_header "paperless-upstream" $paperless_upstream always;
|
|
|
|
# rewrite ^ $request_uri;
|
|
#rewrite '^/\w*(/ws/.*)$' $1 break;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_redirect off;
|
|
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-Host $server_name;
|
|
|
|
proxy_pass http://$paperless_upstream;
|
|
}
|
|
|
|
access_log /var/log/nginx/access_{{ paperless_url }}.log main;
|
|
error_log /var/log/nginx/error_{{ paperless_url }}.log warn;
|
|
|
|
ssl_session_timeout 5m;
|
|
ssl_certificate /usr/local/etc/certs/{{ paperless_url }}/fullchain.pem;
|
|
ssl_certificate_key /usr/local/etc/certs/{{ paperless_url }}/privkey.pem;
|
|
|
|
fastcgi_hide_header X-Powered-By;
|
|
}
|