infra/roles/audiobookshelf/templates/02-audiobookshelf.conf.j2

112 lines
3.5 KiB
Django/Jinja

map $request_uri $kill_stupid_serviceworker_cache {
~*^/_nuxt/(.*)\.js$ 1;
}
{#
server {
listen 443 ssl http2;
include listen-proxy-protocol.conf;
{% if inventory_hostname in wg_clients -%}
listen {{ wg_clients[inventory_hostname].ip }}:443 ssl http2;
{% endif -%}
server_name {{ audiobookshelf_url_short }};
ssl_certificate /usr/local/etc/certs/{{ audiobookshelf_url_short }}/fullchain.pem;
ssl_certificate_key /usr/local/etc/certs/{{ audiobookshelf_url_short }}/privkey.pem;
location / {
proxy_pass https://localhost;
proxy_set_header "Host" "{{ audiobookshelf_url }}";
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_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_redirect https://{{ audiobookshelf_url }}/ https://{{ audiobookshelf_url_short }}/;
proxy_set_header Accept-Encoding "";
}
}
#}
server {
listen 443 ssl http2;
include listen-proxy-protocol.conf;
{% if inventory_hostname in wg_clients -%}
listen {{ wg_clients[inventory_hostname].ip }}:443 ssl http2;
{% endif -%}
server_name {{ audiobookshelf_url }};
access_log /var/log/nginx/access_{{ audiobookshelf_url }}.log main;
error_log /var/log/nginx/error_{{ audiobookshelf_url }}.log warn;
ssl_certificate /usr/local/etc/certs/{{ audiobookshelf_url }}/fullchain.pem;
ssl_certificate_key /usr/local/etc/certs/{{ audiobookshelf_url }}/privkey.pem;
include /etc/nginx/authelia_internal.conf;
location /feed/ {
#include /etc/nginx/require_auth.conf;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_pass http://{{ bridgewithdns.audiobookshelf }}:80;
proxy_redirect http:// https://;
#proxy_hide_header "Content-Type";
#add_header "Content-Type" "application/rss+xml";
}
location /socket.io/ {
#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;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_pass http://{{ bridgewithdns.audiobookshelf }}:80;
}
location / {
#include /etc/nginx/require_auth.conf;
if ($kill_stupid_serviceworker_cache) {
rewrite "^(.*)$" "$1?id=$request_id" redirect;
}
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
# nuke cache
add_header Last-Modified $date_gmt always;
add_header Cache-Control 'no-store' always;
if_modified_since off;
expires off;
etag off;
# nuke the service worker cache
sub_filter '.js' '.js?id=$request_id';
proxy_pass http://{{ bridgewithdns.audiobookshelf }}:80;
proxy_redirect http:// https://;
}
}