I was able to achieve this on my Wordpress site (being served with NGINX) by doing the following:
This assumes you have already setup your Wordpress site to use https with a clearnet domain on nginx.
- In your /etc/tor/torrc file, add the following:
HiddenServiceDir /var/lib/tor/exampleonion
HiddenServicePort 80 127.0.0.1:8022 #Replace 8022 with another port if you want. NOT 443 or 80
- Get your onion site address by running:
sudo cat /var/lib/tor/exampleonion/hostname
Create a new nginx file in /etc/nginx/sites-available/
name it example.onion.conf or whatever you want
In the file add this then restart nginx:
server {
listen putyourtorporthere;
server_name youronionaddresshere.onion;
#The rest should be the same as your clearnet Wordpress site
root /var/www/example.com/wordpress/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass wp-php-handler;
}
}
Visit your site using the CLEARNET domain and install and activate the Multiple Domain plugin by goINPUT IT Solutions.
In the Settings-General panel, add your onion domain under the Multiple Domain settings. BE SURE TO SELECT HTTP instead of "Auto" for your onion site since onion certs are not currently easily available.
Test your site in the Tor browser using the onion domain.
To add the "Onion available" message on Tor, add the following to your CLEARNET Nginx config.
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header Onion-Location http://youronionaddresshere.onion$request_uri;
- Restart nginx and visit the CLEARNET domain in Tor to see if the banner appears once the site loads.