I've seen that onion.to gateway, is redirecting the

client to .onion when the site was accessed over tor.

How to implement it in nginx anybody have ideas?


There are a few approaches you can take:

  1. Use Tor DNSEL or ExitList to detect known Tor exits and redirect them if they are coming from a known Tor exit.

  2. Load embed a <script> tag with the source being the .onion, with javascript check if the hostname is the .onion address and if it isn't then redirect the user to it.

  3. Without javascript, use .css instead to prompt a user to visit the onion address. Embed an element on the page and hide it with a CSS stylesheet. Load another stylesheet from the .onion, if it is loaded it will unhide the element that recommends the user use the .onion instead.

I've an example implementation of the last 2 options here, in this case specifically using PHP but the concepts could be transfered to other languages (and probably improved, web development isn't my forte).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.