Update Caddyfile

- Access-Control-Allow-Origin "*" only for /status, /config
- Add Strict-Transport-Security
- Modify Content-Security-Policy to allow https://www.deezer.com https://www.mixcloud.com https://w.soundcloud.com https://embed.spotify.com
- Limit request header/body to 10kb
This commit is contained in:
Dalf 2019-07-13 10:59:07 +02:00
parent ba3507d96b
commit 1b6563ffe0
1 changed files with 40 additions and 44 deletions

View File

@ -1,46 +1,51 @@
{$SEARX_PROTOCOL}{$SEARX_HOSTNAME} { {$SEARX_PROTOCOL}{$SEARX_HOSTNAME} {
tls {$SEARX_TLS} tls {$SEARX_TLS}
gzip { gzip {
not /morty not /morty
} }
root /srv root /srv
header /config {
Access-Control-Allow-Methods "GET, OPTIONS"
Access-Control-Allow-Origin "*"
}
header /status {
Access-Control-Allow-Methods "GET, OPTIONS"
Access-Control-Allow-Origin "*"
}
header / { header / {
# Enable HTTP Strict Transport Security (HSTS) to force clients to always # Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
# connect via HTTPS Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# Enable cross-site filter (XSS) and tell browser to block detected attacks # Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block" X-XSS-Protection "1; mode=block"
# 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"
# Disallow the site to be rendered within a frame (clickjacking protection) # Disallow the site to be rendered within a frame (clickjacking protection)
X-Frame-Options "SAMEORIGIN" X-Frame-Options "SAMEORIGIN"
# CSP (see http://content-security-policy.com/ ) # CSP (see http://content-security-policy.com/ )
Content-Security-Policy "default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; form-action 'self'; 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 http://www.youtube-nocookie.com http://player.vimeo.com http://www.dailymotion.com" Content-Security-Policy "default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; form-action 'self'; 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"
# # Disable some features
Access-Control-Allow-Methods "GET, POST, OPTIONS" Feature-Policy "accelerometer 'none';autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';gyroscope 'none';magnetometer 'none';microphone 'none';midi 'none';notifications 'none';payment 'none';push 'none';speaker 'none';sync-xhr 'none';usb 'none';vibrate 'none';vr 'none'"
Access-Control-Allow-Origin "*"
# Disable some features # Cache
Feature-Policy "accelerometer 'none';autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';gyroscope 'none';magnetometer 'none';microphone 'none';midi 'none';notifications 'none';payment 'none';push 'none';speaker 'none';sync-xhr 'none';usb 'none';vibrate 'none';vr 'none'" Cache-Control "no-cache, no-store"
Pragma "no-cache"
# Cache # Referer
Cache-Control "no-cache, no-store" Referrer-Policy "no-referrer"
Pragma "no-cache"
# Referer # X-Robots-Tag
Referrer-Policy "no-referrer" X-Robots-Tag "noindex, noarchive, nofollow"
# X-Robots-Tag # Remove Server header
X-Robots-Tag "noindex, noarchive, nofollow" -Server
# Remove Server header
-Server
} }
header /morty { header /morty {
@ -48,15 +53,8 @@
} }
header /static { header /static {
Cache-Control "public, max-age=31536000" Cache-Control "public, max-age=31536000"
-Pragma -Pragma
}
cache {
match_path /static
status_header X-Cache-Status
default_max_age 12h
path /tmp/caddy-cache
} }
rewrite / { rewrite / {
@ -66,7 +64,11 @@
proxy / 127.0.0.1:4040 { proxy / 127.0.0.1:4040 {
transparent transparent
except /searx-checker/status.json header_upstream X-Forwarded-TlsProto {tls_protocol}
header_upstream X-Forwarded-TlsCipher {tls_cipher}
header_upstream X-Forwarded-HttpsProto {proto}
except /searx-checker/status.json
} }
basicauth /filtron {$FILTRON_USER} {$FILTRON_PASSWORD} basicauth /filtron {$FILTRON_USER} {$FILTRON_PASSWORD}
@ -76,12 +78,6 @@
proxy /morty 127.0.0.1:3000 proxy /morty 127.0.0.1:3000
limits { limits 10KB
header 100KB
body / 100KB
body /morty 5MB
}
# ratelimit * /morty 150 300 hour
} }