map $http_user_agent $cli { default 0; ~*wget 1; ~*curl 1; } server { server_name up.chud.cyou; root /var/www/up.chud.cyou; listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; ssl_certificate ...; ssl_certificate_key ...; error_page 404 https://up.chud.cyou/chud/404; location ~ /\.git { deny all; } client_max_body_size 100m; location = /(style.css|title.png) { try_files $uri =404; } location = /upchud.tcl { # include authorized; # deny all; include fastcgi_params; fastcgi_pass unix:/var/run/fcgiwrap.socket; fastcgi_param SCRIPT_FILENAME /var/www/up.chud.cyou/upchud.tcl; } location ^~ /out/ { default_type text/plain; autoindex on; } set $send 0; if ($request_method = PUT) { set $send 1; } if ($request_method = POST) { set $send 1; } set $cli $cli$send; if ($cli = 11) { rewrite ^/.*$ /upchud.tcl last; } rewrite ^/$ /index.html last; rewrite ^/upchud.tcl$ /upchud.tcl last; rewrite ^/style.css$ /style.css last; rewrite ^/title.png$ /title.png last; rewrite ^/(.+)$ /out/$1; }