# Pass path to thttpd for CGI

**URL:** <https://www.ruby-forum.com/t/pass-path-to-thttpd-for-cgi/239982>\
**Category:** NGINX\
**Created:** [March 22, 2014, 10:18pm UTC](https://www.ruby-forum.com/t/pass-path-to-thttpd-for-cgi/239982 "2014-03-22T22:18:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [March 22, 2014, 10:18pm UTC](https://www.ruby-forum.com/t/pass-path-to-thttpd-for-cgi/239982/1 "2014-03-22T22:18:59Z")

</div>

I sort of have this working but not quite. I have  
[http://mysite.com/music/play/song.mp3](http://mysite.com/music/play/song.mp3) and this plays fine in the browser  
by accessing the mp3 file in its folder. However, I want to handle  
requests to download the song at  
[http://mysite.com/music/download/song.mp3](http://mysite.com/music/download/song.mp3) with a CGI script that has no  
extension (it’s C). I can get /music/download to be handled by CGI in  
thttpd but I don’t know how to handle the changing song titles cause  
everything I’ve tried fails.

location /music {  
try\_files $uri.html $uri/index.html @music;  
}

location @music {  
proxy\_pass [http://127.0.0.1:8000](http://127.0.0.1:8000);  
}

In thttpd.conf I have:  
host=127.0.0.1  
port=8000  
dir=/www/cgi-bin  
cgipat=/\*\*

And inside the cgi-bin is a standalone program called “download” so  
/music/download returns a web page generated by that executable just to  
test this. I’ve tried so many variations including rewrite that I’ve  
gotten myself pretty turned around as to what I should be doing.

---

<div class="post-metadata">

**Author:** ![doc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f07891/32.png) [@doc](https://www.ruby-forum.com/u/doc)\
**Post date:** [March 24, 2014, 2:28pm UTC](https://www.ruby-forum.com/t/pass-path-to-thttpd-for-cgi/239982/2 "2014-03-24T14:28:55Z")

</div>

On Sat, Mar 22, 2014 at 05:18:19PM -0400, Doc wrote:

Hi there,

> I can get /music/download to be handled by CGI in  
> thttpd but I don’t know how to handle the changing song titles cause  
> everything I’ve tried fails.

I don’t see any nginx problems here.

Can you request the download of thttpd directly? If you can’t, nginx  
can’t.

If you can, post the curl command you use to get it, and you may have  
better luck here.

Good luck with it,

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
