caddyfmt on the templated Caddyfile as well

This commit is contained in:
Arya 2024-11-17 17:55:56 +05:30
parent 0782130f36
commit bf4cca9ec9
Signed by: arya
GPG Key ID: 842D12BDA50DF120

View File

@ -4,191 +4,190 @@
} }
(tor) { (tor) {
header { header {
-Strict-Transport-Security -Strict-Transport-Security
-Referrer-Policy -Referrer-Policy
-Content-Security-Policy -Content-Security-Policy
# disable clients from sniffing the media type # disable clients from sniffing the media type
X-Content-Type-Options nosniff X-Content-Type-Options nosniff
Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), clipboard-read=(), display-capture=(), document-domain=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), interest-cohort=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), serial=(), usb=(), sync-xhr=(), xr-spatial-tracking=()"; Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), clipboard-read=(), display-capture=(), document-domain=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), interest-cohort=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), serial=(), usb=(), sync-xhr=(), xr-spatial-tracking=()";
# clickjacking protection # clickjacking protection
X-Frame-Options SAMEORIGIN X-Frame-Options SAMEORIGIN
Onion-Location http://{args[0]}.pjsfkvpxlinjamtawaksbnnaqs2fc2mtvmozrzckxh7f3kis6yea25ad.onion{path} Onion-Location http://{args[0]}.pjsfkvpxlinjamtawaksbnnaqs2fc2mtvmozrzckxh7f3kis6yea25ad.onion{path}
defer defer
} }
} }
(torloc) { (torloc) {
header Onion-Location http://{args[0]}.pjsfkvpxlinjamtawaksbnnaqs2fc2mtvmozrzckxh7f3kis6yea25ad.onion{path} header Onion-Location http://{args[0]}.pjsfkvpxlinjamtawaksbnnaqs2fc2mtvmozrzckxh7f3kis6yea25ad.onion{path}
} }
(acmedns) { (acmedns) {
tls { tls {
dns rfc2136 { dns rfc2136 {
key_name "dynupd" key_name "dynupd"
key_alg "hmac-sha256" key_alg "hmac-sha256"
key "{{ rfc2136_key }}" key "{{ rfc2136_key }}"
server "45.145.41.226:53" server "45.145.41.226:53"
} }
} }
} }
(def) { (def) {
header { header {
# disable FLoC tracking # disable FLoC tracking
Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), clipboard-read=(), display-capture=(), document-domain=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), interest-cohort=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), serial=(), usb=(), sync-xhr=(), xr-spatial-tracking=()"; Permissions-Policy "accelerometer=(), ambient-light-sensor=(), autoplay=(), battery=(), camera=(), clipboard-read=(), display-capture=(), document-domain=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), hid=(), idle-detection=(), interest-cohort=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), serial=(), usb=(), sync-xhr=(), xr-spatial-tracking=()";
# enable HSTS # enable HSTS
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# disable clients from sniffing the media type # disable clients from sniffing the media type
X-Content-Type-Options nosniff X-Content-Type-Options nosniff
# clickjacking protection # clickjacking protection
X-Frame-Options SAMEORIGIN X-Frame-Options SAMEORIGIN
defer defer
} }
log { log {
# Anonymised IPs, User-Agents, and Cookies, also removed the URI as mentionned in the privacy policy. # Anonymised IPs, User-Agents, and Cookies, also removed the URI as mentionned in the privacy policy.
# Subject to change, if we find any missing config we haven't filtered, it will be added. # Subject to change, if we find any missing config we haven't filtered, it will be added.
output file /var/log/caddy/caddy.log output file /var/log/caddy/caddy.log
format filter { format filter {
wrap json wrap json
fields { fields {
request>remote_ip ip_mask { request>remote_ip ip_mask {
ipv4 16 ipv4 16
ipv6 64 ipv6 64
} }
request>client_ip ip_mask { request>client_ip ip_mask {
ipv4 16 ipv4 16
ipv6 64 ipv6 64
} }
request>headers>X-Forwarded-For ip_mask { request>headers>X-Forwarded-For ip_mask {
ipv4 16 ipv4 16
ipv6 64 ipv6 64
} }
request>headers>Cookie cookie { request>headers>Cookie cookie {
replace session REDACTED replace session REDACTED
delete secret delete secret
} }
request>headers>User-Agent delete request>headers>User-Agent delete
request>headers>Onion-Location delete request>headers>Onion-Location delete
request>headers>Referer delete request>headers>Referer delete
request>uri replace "/ABCDF" request>uri replace "/ABCDF"
} }
}
} }
@denied client_ip {{ blocked_ranges }} }
respond @denied "Unfortunately, your IP is part of a range that has been involved in mass spam to our servers. If you think our action was a mistake, please email contact@projectsegfau.lt." 403 @denied client_ip {{ blocked_ranges }}
respond @denied "Unfortunately, your IP is part of a range that has been involved in mass spam to our servers. If you think our action was a mistake, please email contact@projectsegfau.lt." 403
import acmedns
import acmedns
} }
import ./*.Caddyfile import ./*.Caddyfile
{{ inventory_hostname }}.projectsegfau.lt {% if inventory_hostname == 'eu' %} pizza1.projectsegfau.lt {% endif %} { {{ inventory_hostname }}.projectsegfau.lt {% if inventory_hostname == 'eu' %} pizza1.projectsegfau.lt {% endif %} {
redir https://wiki.projectsegfau.lt/index.php?title={{ wiki_page }} redir https://wiki.projectsegfau.lt/index.php?title={{ wiki_page }}
} }
cdn.projectsegfau.lt cdn.{{ server_prefix }}.projectsegfau.lt { cdn.projectsegfau.lt cdn.{{ server_prefix }}.projectsegfau.lt {
encode zstd gzip encode zstd gzip
root * /var/cdn root * /var/cdn
file_server { file_server {
browse browse
} }
import def import def
} }
lbry.{{ server_prefix }}.projectsegfau.lt lbry.projectsegfau.lt { lbry.{{ server_prefix }}.projectsegfau.lt lbry.projectsegfau.lt {
reverse_proxy :3550 reverse_proxy :3550
import def import def
import torloc lbry import torloc lbry
} }
# We need this inventory_hostname block since nitter is only going to be on EU from now on # We need this inventory_hostname block since nitter is only going to be on EU from now on
{% if inventory_hostname == 'eu' %} {% if inventory_hostname == 'eu' %}
nitter.eu.projectsegfau.lt nitter.us.projectsegfau.lt nitter.in.projectsegfau.lt nitter.projectsegfau.lt n.psf.lt n.eu.psf.lt n.us.psf.lt n.in.psf.lt { nitter.eu.projectsegfau.lt nitter.us.projectsegfau.lt nitter.in.projectsegfau.lt nitter.projectsegfau.lt n.psf.lt n.eu.psf.lt n.us.psf.lt n.in.psf.lt {
import def import def
import torloc nitter import torloc nitter
reverse_proxy :8387 reverse_proxy :8387
basicauth { basicauth {
{% for item in private_service_basicauth %} {% for item in private_service_basicauth %}
{{ item }} {{ item }}
{% endfor %} {% endfor %}
} }
} }
{% endif %} {% endif %}
libreddit.{{ server_prefix }}.projectsegfau.lt libreddit.projectsegfau.lt lr.psf.lt lr.{{ server_prefix }}.psf.lt { libreddit.{{ server_prefix }}.projectsegfau.lt libreddit.projectsegfau.lt lr.psf.lt lr.{{ server_prefix }}.psf.lt {
reverse_proxy :6464 reverse_proxy :6464
import def import def
log { log {
# This is temporarily required to monitor nitter traffic due to scrapers being more active, so we need to monitor and rate limit them at a later date. # This is temporarily required to monitor nitter traffic due to scrapers being more active, so we need to monitor and rate limit them at a later date.
output file /var/log/caddy/ratelimiters.log output file /var/log/caddy/ratelimiters.log
format json format json
} }
import torloc libreddit import torloc libreddit
} }
teddit.{{ server_prefix }}.projectsegfau.lt teddit.projectsegfau.lt t.psf.lt t.{{ server_prefix }}.psf.lt { teddit.{{ server_prefix }}.projectsegfau.lt teddit.projectsegfau.lt t.psf.lt t.{{ server_prefix }}.psf.lt {
redir https://libreddit.projectsegfau.lt{uri} redir https://libreddit.projectsegfau.lt{uri}
import def import def
import torloc teddit import torloc teddit
} }
inv.{{ server_prefix }}.projectsegfau.lt i.{{ server_prefix }}.psf.lt { inv.{{ server_prefix }}.projectsegfau.lt i.{{ server_prefix }}.psf.lt {
reverse_proxy :7573 { reverse_proxy :7573 {
header_up Host "inv.{{server_prefix}}.projectsegfau.lt" header_up Host "inv.{{ server_prefix }}.projectsegfau.lt"
} }
@pipedproxy { @pipedproxy {
path /videoplayback path /videoplayback
path /videoplayback/* path /videoplayback/*
path /vi/* path /vi/*
path /ggpht/* path /ggpht/*
} }
handle @pipedproxy { handle @pipedproxy {
reverse_proxy :6970 { reverse_proxy :6970 {
header_up Host "pipedproxy.{{server_prefix}}.projectsegfau.lt" header_up Host "pipedproxy.{{ server_prefix }}.projectsegfau.lt"
} }
@jpgRedirect path_regexp maxres2 /vi/(.+)/maxres.jpg @jpgRedirect path_regexp maxres2 /vi/(.+)/maxres.jpg
@thumbnailRedirect path /ggpht/* @thumbnailRedirect path /ggpht/*
uri @thumbnailRedirect strip_prefix /ggpht uri @thumbnailRedirect strip_prefix /ggpht
rewrite @thumbnailRedirect ?host=yt3.ggpht.com rewrite @thumbnailRedirect ?host=yt3.ggpht.com
uri @jpgRedirect replace /maxres.jpg /maxres2.jpg uri @jpgRedirect replace /maxres.jpg /maxres2.jpg
rewrite /vi/* ?host=i.ytimg.com rewrite /vi/* ?host=i.ytimg.com
} }
import def import def
header -X-Frame-Options header -X-Frame-Options
header -Content-Security-Policy header -Content-Security-Policy
@ratelimit not path /videoplayback/* /ggpht/* /vi/* /videoplayback /videojs/* /css/* /js/* /fonts/* /apple-touch-icon.png /favicon-16x16.png /feed/webhook /feed/webhook/* @ratelimit not path /videoplayback/* /ggpht/* /vi/* /videoplayback /videojs/* /css/* /js/* /fonts/* /apple-touch-icon.png /favicon-16x16.png /feed/webhook /feed/webhook/*
rate_limit @ratelimit {remote.ip} 10r/s rate_limit @ratelimit {remote.ip} 10r/s
rate_limit @ratelimit {remote.ip} 100r/m rate_limit @ratelimit {remote.ip} 100r/m
@ratelimit_pubsub path /feed/webhook /feed/webhook/* @ratelimit_pubsub path /feed/webhook /feed/webhook/*
rate_limit @ratelimit_pubsub {remote.ip} 2r/s 404 rate_limit @ratelimit_pubsub {remote.ip} 2r/s 404
log { log {
# This is temporarily required to monitor nitter traffic due to scrapers being more active, so we need to monitor and rate limit them at a later date. # This is temporarily required to monitor nitter traffic due to scrapers being more active, so we need to monitor and rate limit them at a later date.
output file /var/log/caddy/ratelimiters.log output file /var/log/caddy/ratelimiters.log
format json format json
} }
} }
gothub.{{ server_prefix }}.projectsegfau.lt gothub.projectsegfau.lt gh.psf.lt gh.{{ server_prefix }}.psf.lt { gothub.{{ server_prefix }}.projectsegfau.lt gothub.projectsegfau.lt gh.psf.lt gh.{{ server_prefix }}.psf.lt {
reverse_proxy :1024 reverse_proxy :1024
import def import def
import torloc gothub import torloc gothub
} }
overflow.{{ server_prefix }}.projectsegfau.lt overflow.projectsegfau.lt o.psf.lt o.{{ server_prefix }}.psf.lt { overflow.{{ server_prefix }}.projectsegfau.lt overflow.projectsegfau.lt o.psf.lt o.{{ server_prefix }}.psf.lt {
reverse_proxy :8694 reverse_proxy :8694
import def import def
import torloc overflow import torloc overflow
} }
rimgo.{{ server_prefix }}.projectsegfau.lt rimgo.projectsegfau.lt rg.psf.lt rg.{{ server_prefix }}.psf.lt { rimgo.{{ server_prefix }}.projectsegfau.lt rimgo.projectsegfau.lt rg.psf.lt rg.{{ server_prefix }}.psf.lt {
reverse_proxy :9016 reverse_proxy :9016
import def import def
import torloc rimgo import torloc rimgo
} }
bw.{{ server_prefix }}.projectsegfau.lt bw.projectsegfau.lt bw.psf.lt bw.{{ server_prefix }}.psf.lt { bw.{{ server_prefix }}.projectsegfau.lt bw.projectsegfau.lt bw.psf.lt bw.{{ server_prefix }}.psf.lt {
import def import def
import torloc breezewiki import torloc breezewiki
reverse_proxy :10416 reverse_proxy :10416
} }
scribe.{{ server_prefix }}.projectsegfau.lt scribe.projectsegfau.lt sc.psf.lt sc.{{ server_prefix }}.psf.lt { scribe.{{ server_prefix }}.projectsegfau.lt scribe.projectsegfau.lt sc.psf.lt sc.{{ server_prefix }}.psf.lt {
import def import def
import torloc scribe import torloc scribe
reverse_proxy :8006 reverse_proxy :8006
} }
translate.{{ server_prefix }}.projectsegfau.lt translate.projectsegfau.lt tl.psf.lt tl.{{ server_prefix }}.psf.lt { translate.{{ server_prefix }}.projectsegfau.lt translate.projectsegfau.lt tl.psf.lt tl.{{ server_prefix }}.psf.lt {
import def import def
@ -214,80 +213,80 @@ hyperpipebackend.{{ server_prefix }}.projectsegfau.lt {
import def import def
} }
search.{{ server_prefix }}.projectsegfau.lt search.projectsegfau.lt s.psf.lt s.{{ server_prefix }}.psf.lt { search.{{ server_prefix }}.projectsegfau.lt search.projectsegfau.lt s.psf.lt s.{{ server_prefix }}.psf.lt {
import def import def
import torloc search import torloc search
reverse_proxy :8081 { reverse_proxy :8081 {
header_up X-Real-IP {remote_host} header_up X-Real-IP {remote_host}
} }
@api { @api {
path /config path /config
path /healthz path /healthz
path /stats/errors path /stats/errors
path /stats/checker path /stats/checker
} }
@static { @static {
path /static/* path /static/*
} }
@notstatic { @notstatic {
not path /static/* not path /static/*
} }
@imageproxy { @imageproxy {
path /image_proxy path /image_proxy
} }
@notimageproxy { @notimageproxy {
not path /image_proxy not path /image_proxy
} }
header { header {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS # Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
X-Content-Type-Options "nosniff" X-Content-Type-Options "nosniff"
# Disable some features # Disable some features
Permissions-Policy "accelerometer=(),ambient-light-sensor=(),autoplay=(),camera=(),encrypted-media=(),focus-without-user-activation=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),speaker=(),sync-xhr=(),usb=(),vr=()" Permissions-Policy "accelerometer=(),ambient-light-sensor=(),autoplay=(),camera=(),encrypted-media=(),focus-without-user-activation=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),speaker=(),sync-xhr=(),usb=(),vr=()"
# Disable some features (legacy) # Disable some features (legacy)
Feature-Policy "accelerometer 'none';ambient-light-sensor 'none'; autoplay 'none';camera 'none';encrypted-media 'none';focus-without-user-activation 'none'; geolocation 'none';gyroscope 'none';magnetometer 'none';microphone 'none';midi 'none';payment 'none';picture-in-picture 'none'; speaker 'none';sync-xhr 'none';usb 'none';vr 'none'" Feature-Policy "accelerometer 'none';ambient-light-sensor 'none'; autoplay 'none';camera 'none';encrypted-media 'none';focus-without-user-activation 'none'; geolocation 'none';gyroscope 'none';magnetometer 'none';microphone 'none';midi 'none';payment 'none';picture-in-picture 'none'; speaker 'none';sync-xhr 'none';usb 'none';vr 'none'"
# Referer # Referer
Referrer-Policy "no-referrer" Referrer-Policy "no-referrer"
# X-Robots-Tag # X-Robots-Tag
X-Robots-Tag "noindex, noarchive, nofollow" X-Robots-Tag "noindex, noarchive, nofollow"
# Remove Server header # Remove Server header
-Server -Server
} }
import acmedns import acmedns
header @api { header @api {
Access-Control-Allow-Methods "GET, OPTIONS" Access-Control-Allow-Methods "GET, OPTIONS"
Access-Control-Allow-Origin "*" Access-Control-Allow-Origin "*"
} }
# Cache # Cache
header @static { header @static {
# Cache # Cache
Cache-Control "public, max-age=31536000" Cache-Control "public, max-age=31536000"
defer defer
} }
header @notstatic { header @notstatic {
# No Cache # No Cache
Cache-Control "no-cache, no-store" Cache-Control "no-cache, no-store"
Pragma "no-cache" Pragma "no-cache"
} }
# CSP (see http://content-security-policy.com/ ) # CSP (see http://content-security-policy.com/ )
header @imageproxy { header @imageproxy {
Content-Security-Policy "default-src 'none'; img-src 'self' data:" Content-Security-Policy "default-src 'none'; img-src 'self' data:"
} }
header @notimageproxy { header @notimageproxy {
Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self' https://github.com/searxng/searxng/issues/new; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src 'self' data: https://*.tile.openstreetmap.org; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com" Content-Security-Policy "upgrade-insecure-requests; default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self' https://github.com/searxng/searxng/issues/new; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self' https://overpass-api.de; img-src 'self' data: https://*.tile.openstreetmap.org; frame-src https://www.youtube-nocookie.com https://player.vimeo.com https://www.dailymotion.com https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com"
} }
} }
piped.{{ server_prefix }}.projectsegfau.lt pipedproxy.{{ server_prefix }}.projectsegfau.lt pipedapi.{{ server_prefix }}.projectsegfau.lt { piped.{{ server_prefix }}.projectsegfau.lt pipedproxy.{{ server_prefix }}.projectsegfau.lt pipedapi.{{ server_prefix }}.projectsegfau.lt {
reverse_proxy :6970 reverse_proxy :6970
header -X-Frame-Options header -X-Frame-Options
import def import def
} }
pi.{{ server_prefix }}.psf.lt { pi.{{ server_prefix }}.psf.lt {
reverse_proxy :6970 { reverse_proxy :6970 {
header_up Host "{% if server_prefix == 'eu' %}piped.projectsegfau.lt{%else%}piped.{{ server_prefix }}.projectsegfau.lt{%endif%}" header_up Host "{% if server_prefix == 'eu' %}piped.projectsegfau.lt{%else%}piped.{{ server_prefix }}.projectsegfau.lt{%endif%}"
} }
header -X-Frame-Options header -X-Frame-Options
import def import def
} }
priviblur.{{ server_prefix }}.projectsegfau.lt priviblur.projectsegfau.lt pb.psf.lt pb.{{ server_prefix }}.psf.lt { priviblur.{{ server_prefix }}.projectsegfau.lt priviblur.projectsegfau.lt pb.psf.lt pb.{{ server_prefix }}.psf.lt {
import def import def