location / { root /home/xxxx; index index.html index.htm; set $fname $request_filename; proxy_pass http://xx.xxx.xxx.xxx:8080/; proxy_redirect off; } location /dl { root /home/xxx/1; internal; post_action /download-stop; } location /cgi-bin/ { proxy_pass http://xx.xxx.xxx.xxx:8080/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /download-stop { internal; rewrite ^ /cgi-bin/dwnl_stop.php?bs=$body_bytes_sent&fname=$fname&rem_addr=$remote_addr last; }