58 lines
2.0 KiB
Nginx Configuration File
58 lines
2.0 KiB
Nginx Configuration File
map $http_referer $luphoto_hotlink {
|
|
default 1;
|
|
"" 0;
|
|
"~^https?://photos\.luciochen\.com(:[0-9]+)?(/|$)" 0;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
http2 on;
|
|
server_name photos.luciochen.com;
|
|
|
|
ssl_certificate /etc/letsencrypt/live/photos.luciochen.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/photos.luciochen.com/privkey.pem;
|
|
|
|
root /var/lib/luphoto/site/current;
|
|
index index.html;
|
|
autoindex off;
|
|
disable_symlinks off;
|
|
gzip_static on;
|
|
server_tokens off;
|
|
|
|
if ($request_method !~ ^(GET|HEAD)$) {
|
|
return 405;
|
|
}
|
|
|
|
location ~ (/\.|\.gz$) {
|
|
return 404;
|
|
}
|
|
|
|
location /t/ {
|
|
if ($luphoto_hotlink) {
|
|
return 403;
|
|
}
|
|
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
add_header Content-Security-Policy "default-src 'self'; img-src 'self' blob: data:; font-src 'self'; worker-src 'self'; frame-ancestors 'none'" always;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
|
try_files $uri =404;
|
|
}
|
|
|
|
location ~ ^/(og|assets)/ {
|
|
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
add_header Content-Security-Policy "default-src 'self'; img-src 'self' blob: data:; font-src 'self'; worker-src 'self'; frame-ancestors 'none'" always;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
|
try_files $uri =404;
|
|
}
|
|
|
|
location / {
|
|
add_header Cache-Control "public, max-age=60" always;
|
|
add_header Content-Security-Policy "default-src 'self'; img-src 'self' blob: data:; font-src 'self'; worker-src 'self'; frame-ancestors 'none'" always;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
|
try_files $uri $uri/index.html =404;
|
|
}
|
|
}
|