Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a way to redirect to a local HTML file for any blacklisted host file addresses? Something like "You tried to access a site that's blocked in hosts file"? I tend to add blacklists like this then few months later wonder why some site doesn't work.


Yes. As the hosts file redirects to localhosts, you can run a local server, displaying a notification. As root:

    while true; do printf "blocked by hosts file" |nc -q 1 -l -p 80; done


You can run a server at 127.0.0.1:80, but it won’t work for HTTPS sites… unless you also configure your own certificates on the server.


That won't help if the site fails due to a backend request to FB falling over.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: