Files
LuPhoto/packaging/nginx.conf
T
lucioandClaude Opus 5.5 c87aad0254 Risk-based robot check with server-issued photo keys
The main page and direct photo links open without a prompt. Each
photo's pool is sealed with its own key, handed out by POST /k
(served by the daemon in serve and export mode). The hold-and-solve
card appears only for low-entropy clicks into a collection, too many
low-entropy landings from one IP, or more than photo_limit photos per
window, with escalating proof-of-work and a 429 cap. Build ids now
sort chronologically within the same second.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 22:45:50 -08:00

82 lines
2.8 KiB
Nginx Configuration File

map $http_referer $luphoto_hotlink {
default 1;
"" 0;
"~^https?://photos\.luciochen\.com(:[0-9]+)?(/|$)" 0;
}
map "$request_method $uri" $luphoto_bad_method {
default 1;
"~^(GET|HEAD) " 0;
"POST /k" 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;
error_page 404 /404.html;
if ($luphoto_bad_method) {
return 405;
}
location ~ (/\.|\.gz$) {
return 404;
}
location = /k {
client_max_body_size 4k;
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection "";
}
location = /404.html {
internal;
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;
}
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;
}
}