How to set up a tor website?

Install tor 

sudo apt install tor
sudo apt install obfs4proxy

Modify configs

# sudo vim /etc/tor/torrc

HiddenServiceDir /root/a_website_config
HiddenServicePort 80 127.0.0.1:8080

#ClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy
#UseBridges 1
#Bridge obfs4 85.22.11.28:443 alsdfkalhsdfkh cert=akdfkhdakjfdhkjahfkl iat-mode=0

Modify permissions

sudo mkdir -p /root/a_website_config
cd /root
sudo chmod 700 a_website_config

Start tor service

sudo -u root tor

Check the “/root/a_website_config/hostname”

So you can get your union url: *.union

Install tor browser

https://www.torproject.org/download

  1. Set up obfs4 bridge
  2. When you connect successfully, go to settings, connections, copy a bridge link to somewhere, you may need it later

Use tor browser to test if you can connect your website or not

If you can connect to your service, go to next step.
If you can’t connect to your service, you need to add a bridge for your hidden service. You need to sudo vim /etc/tor/torrc, uncomment all bridge related configurations.
Then paste the bridge link you copied from tor broswer into that config file.
Restart tor broswer, then you should be able to connect to your service again.

Start tor service forever

sudo systemctl enable tor
sudo systemctl start tor