Onion-Location ayuda promocionar tu sitio .onion fácilmente.
You can either configure a web server to show an Onion-Location Header or add an HTML <meta>
attribute in the website.
Para funcionar la cabecera las siguentes condiciones se ocupa completar:
- La cifra de Onion-Location debe ser una URL válida con protocolo http: o https: y un nombre de host .onion.
- El sitio web que contiene la cabecera de Onion-Location debe servirse a través de HTTPS.
- El sitio web que contiene la cabecera de Onion-Location no puede ser un sitio onion.
En esta página, los comandos para gestionar el servidor web están basados en sistemas operativos derivados de Debian, y pueden diferir de otros sistemas.
Verifica tu documentacion del servidor web y sistema operativo.
Apache
Para configurar la cabecera en Apache 2.2 o mas nuevo, tienes que permitir los módulos headers
y rewrite
y modificar el archivo del sitio web para el servidor virtual.
Paso 1. Permitir cabeceras y reescribir módulos y recargar Apache2
$ sudo a2enmod headers rewrite
$ sudo systemctl reload apache2
Si obtienes un mensaje de error, algo ha salido mal, y no puedes continuar hasta que te hayas dado cuenta de por qué no funcionó.
Paso 2. Añadir la cabecera Onion-Location a tu archivo de configuración para el servidor virtual
Header set Onion-Location "http://your-onion-address.onion%{REQUEST_URI}s"
Where your-onion-address.onion
is the Onion Service address you want to redirect and {REQUEST_URI}
is the path component of the requested URI, such as "/index.html".
Ejemplo del servidor virtual:
<VirtualHost *:443>
ServerName <your-website.tld>
DocumentRoot /path/to/htdocs
Header set Onion-Location "http://your-onion-address.onion%{REQUEST_URI}s"
SSLEngine on
SSLCertificateFile "/path/to/www.example.com.cert"
SSLCertificateKeyFile "/path/to/www.example.com.key"
</VirtualHost>
Paso 3. Recarga Apache
Recarga el servicio apache2, con el fin de que los cambios de configuración tengan efecto:
$ sudo systemctl reload apache2
Si obtienes un mensaje de error, algo ha salido mal, y no puedes continuar hasta que te hayas dado cuenta de por qué no funcionó.
Paso 4. Probando tu Onion-Location
Para probar si Onion-Location está funcionando, descarga los encabezados HTTP del sitio web, por ejemplo:
$ wget --server-response --spider your-website.tld
Look for onion-location
entry and the Onion Service address.
O abre el sitio web en el Navegador Tor, y una etiqueta púrpura aparecerá en la barra de direcciones.
Nginx
Para configurar un encabezado Onion-Location, el operador del servicio primero debería configurar un servicio Onion.
Paso 1. Crea un servicio Onion estableciendo lo siguiente en torrc
:
HiddenServiceDir /var/lib/tor/hs-my-website/
HiddenServiceVersion 3
HiddenServicePort 80 unix:/var/run/tor-hs-my-website.sock
Paso 2. Edita el archivo de configuración del sitio web
In /etc/nginx/conf.d/<your-website>.conf
add the Onion-Location header and the Onion Service address.
Por ejemplo:
add_header Onion-Location http://<your-onion-address>.onion$request_uri;
El archivo de configuración con el Onion-Location debería parecerse a esto:
server {
listen 80;
listen [::]:80;
server_name <your-website.tld>;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name <your-website.tld>;
# managed by Certbot - https://certbot.eff.org/
ssl_certificate /etc/letsencrypt/live/<hostname>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<hostname>/privkey.pem;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header Onion-Location http://<your-onion-address>.onion$request_uri;
# managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
access_log /var/log/nginx/<hostname>-access.log;
index index.html;
root /path/to/htdocs;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen unix:/var/run/tor-hs-my-website.sock;
server_name <your-onion-address>.onion;
access_log /var/log/nginx/hs-my-website.log;
index index.html;
root /path/to/htdocs;
}
Paso 3. Prueba la configuración del sitio web
$ sudo nginx -t
El servidor web debería confirmar que la nueva sintaxis está funcionando:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Paso 4. Reinicia nginx
$ sudo nginx -s reload
Si obtienes un mensaje de error, algo ha salido mal, y no puedes continuar hasta que te hayas dado cuenta de por qué no funcionó.
Paso 5. Probando tu Onion-Location
Para probar si Onion-Location está funcionando, descarga los encabezados HTTP del sitio web, por ejemplo:
$ wget --server-response --spider your-website.tld
Look for onion-location
entry and the Onion Service address.
O abre el sitio web en el Navegador Tor, y una etiqueta púrpura va a aparecer en la barra de direcciones.
Caddy
Caddy incluye HTTPS automático por defecto, por lo que provee tu certificado TLS y se hace cargo de la redirección HTTP-a-HTTPS por ti.
Si estás usando Caddy 2, para incluir un encabezado Onion-Location, agrega la siguiente declaración en tu Caddyfile:
header Onion-Location http://<your-onion-address>.onion{path}
Si estás corriendo un sitio estático y tienes la dirección onion en una variable de entorno $TOR_HOSTNAME
, tu Caddyfile se parecerá a esto:
your-website.tld
header Onion-Location http://{$TOR_HOSTNAME}{path}
root * /var/www
file_server
Probándolo: Pruébalo con:
$ wget --server-response --spider your-website.tld
Look for onion-location
entry and the Onion Service address.
O abre el sitio web en el Navegador Tor, y una etiqueta púrpura va a aparecer en la barra de direcciones.
Usando un <meta>
atributo HTML
El comportamiento idéntico de Onion-Location incluye la opción de definirlo como un <meta>
atributo HTML http-equiv.
Esto podría ser usado por sitios web que prefieren (o necesitan) definir un Onion-Location modificando el contenido HTML servido en vez de agregar un nuevo encabezado HTTP.
The Onion-Location header would be equivalent to a <meta http-equiv="onion-location" content="http://<your-onion-service-address>.onion" />
added in the HTML head element of the webpage. Replace <your-onion-service-address.onion>
with the Onion Service that you want to redirect.
Limitaciones
HTML cannot read the requested URL and insert it dynamically in the http-equiv <meta>
tag.
For this reason, visitors are always redirected to the .onion URL specified in the content-part of the meta tag, regardless of which subpage they are on.
Therefore, if possible, we recommend using one of the above methods.
Más información
Lee la especificación Onion-Location.