This is quite easy if there's no back story to why you feel hosts file is not the right solution. You also might have problems if you're not used to pasting things in Terminal, but if that's the case - you can ask a second question for help on that too!
Copy and paste the following lines into Terminal:
cd mkdir diy_proxy cd diy_proxy cat > index.html << EOF <meta http-equiv="refresh" content="0; url=http://apple.stackexchange.com/" /> EOF python -m SimpleHTTPServer
To kill the python web server, press: Control-C
The lines do the follows:
- get you in your home directory/folder
- make a folder to hold the index file that will redirect your browser
- go to that folder
- send characters to the file index.html until you see EOF (and don't include it)
- This is the magic that tells your browser to redirect
- ends the content to save to file index.html
- start a lightweight web server on port 8000 to serve up the index file
This is possible if you have SSH enabled ("Remote Login" in System Preferences > Sharing)
Then run (in Terminal)
ssh localhost -L 8000:apple.stackexchange.com:80
(You get a shell, type
exit when finished with the proxy.)
With apple.stackexchange.com it gives me this however:
Error 1003 [...]
Direct IP access not allowed
You've requested an IP address that is part of the CloudFlare network. A valid Host header must be supplied to reach the desired website.
To get past that error, you'll need an HTTP level proxy, but ssh might work for some websites.