I had a situation last week where I needed to install macports but due to local proxy behaviour I could not get rsync to work.
However I did have ssh working through the proxy, and I had access to an external system which didn't have the proxy issues... so I created a tunnel.
Now this has to be done as root, as it needs to create a listening port below 1024.
First I changed the /opt/local/etc/macports/sources.conf to point to the localhost
Then I created a tunnel through my external system using ssh
ssh -L 873:rsync.macports.org:873 firstname.lastname@example.org
On that ssh connection I did the following to keep that session active:
ping -i 60 localhost
Now macports quite happily rsync'd away oblivious to the plumbing I had to do. Gotta love ssh.