it seems like an easy question but I cannot find good information. I have built a PHP website that is of course available in the clearnet through the IP and I have a hidden service running (so it is available through an onion address). How do I hide my website in the clearnet and only make it reachable through its onion address through TOR? Thank you
If I understood your question, you want to deny clear net-based access, and only allow tor-based ones. If this is true, you must set up your machine behind an excellent firewall, that don't allow any incoming connections except for those originated from your tor-client. How to do it depends on your environment.
You can also avoid IP connections by not leaking your IP address. Only advertise your
.onion address instead. :)
It's just as simple as putting it behind a reverse proxy: basically, Tor is a reverse TCP proxy for it's hidden services. So - make a separate localhost interface with an address like 127.0.0.2 to make sure that no standard firewall rules will mess up, and just bind your web server to this IP and port. After that make sure to disable any network activity for the web server's user except that new localhost to prevent any data leaks(use a filesystem socket for database connection). That's it! Point your hidden service to 127.0.0.2 and it will work just fine