This will download all dependencies needed to build the package.
apt-get build-dep nginx
Here we will download the sources from Debian repo (Enable src in your sources.list).
apt-get source nginx
Edit the file nginx-0.6.32/auto/options (The version of nginx for you may be different). Look for this line
And change it to:
Enter in the nginx directory.
dpkg-buildpackage -uc -b
sudo dpkg -i ../nginx_0.6.32-3+lenny3_i386.deb
Your version may be different.