server { listen 80; listen [::]:80; auth_basic ""; auth_basic_user_file /etc/nginx/htpasswd/htpasswd_scan; location /scan { content_by_lua_block { epoc = ngx.time(); os.execute("scanimage --format jpeg >/srv/scans/image"..epoc..".jpg"); ngx.redirect("/scans/image"..epoc..".jpg"); } } location /scans { autoindex on; root /srv/; } }