מיקום בצל הנו דרך קלה לפרסם את אתר הבצל למשתמשים. תוכלו לקנפג את שרת האנטרנט להציג Onion-Location Header או הוסיפו תכונות מטה HTML באתר.
כדי שה header יהיה וולידי התנאים הבאים צריכים להתמלא:
- הערך Onion-Location חייב להיות URL תקין עם פרוטוקול http: או https: ושם מארח הבצל
- הדף המגדיר את Onion-Location header חייב להשלח בפרוטוקול HTTPS.
- הדף שמגדיר את Onion-Location header אינו יכול להיות אתר בצל.
בדף הזה, הפקודות לניהול שרת האנטרנט מבוססות על מערכות הפעלה דמויות Debian ויכולות להיות שונות ממערכות אחרות. בדקו את שרת האנטרהט שלכם ותעוד מערכת ההפעלה.
אפאצ'י
כדי להגדיר את ה header הזה ב Apache 2.2 ומעלה, יש להפעיל את המודולים headers
ו rewrite
ולעדכן את קובץ Virtual Host של האתר.
צעד 1. הפעילו את ה headers עדכנו את המודולים modules ואתחלו מחדש את Apache2
$ sudo a2enmod headers rewrite
$ sudo systemctl reload apache2
אם קיבלתם הודעת שגיאה, משהו השתבש ואינכם מצליחים להמשיך עד אשר לבררו מדוע הדבר לא עבד.
צעד 2. הוסיפו Onion-Location header לקובץ הגדרות Virtual Host שלכם
Header set Onion-Location "http://your-onion-address.onion%{REQUEST_URI}s"
באשר your-onion-address.onion
היא הכתובות של שרות הבצל שאתם רוצים לנתב ו {REQUEST_URI}
הוא ה path component of the requested URI, כגון "/index.html".
דוגמת Virtual Host:
<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>
צעד 3. אתחלו מחדש את Apache
אתחלו מחדש את שרת apache2 כדי שההגדרות שלכם יתפסו:
$ sudo systemctl reload apache2
אם קיבלתם הודעת שגיאה, משהו השתבש ואינכם מצליחים להמשיך עד אשר לבררו מדוע הדבר לא עבד.
צעד 4. בדיקת Onion-Location שלכם
כדי לבדוק אם הOnion-Location עובד, הביאו את HTTP headers, למשל:
$ wget --server-response --spider your-website.tld
חפשו את כניסת onion-location
ואת כתובת שרות הבצל.
או פתחו את האתר עם דפדפן Tor ושכבה סגולה תופיע בסרגל הכתובות..
Nginx
כדי להגדיר Onion-Location header, מפעיל השרות חייב קודם כל להגדיר את שרות הבצל.
צעד 1. צרו את שרות הבצל בעזרת ההגדרות הבאות ב torrc
:
HiddenServiceDir /var/lib/tor/hs-my-website/
HiddenServiceVersion 3
HiddenServicePort 80 unix:/var/run/tor-hs-my-website.sock
צעד 2. ערכו את קובץ הגדרות האתר
ב /etc/nginx/conf.d/<your-website>.conf
הוסיפו את Onion-Location header a וכתובת שרות הבצל.
למשל:
add_header Onion-Location http://<your-onion-address>.onion$request_uri;
קובץ ההגדרות עם Onion-Location s צריך להראות משהו כמו:
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>;
# ניהול על ידי 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;
# מנוהל על ידי 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;
}
צעד 3. בדיקת הגדרות אתר
$ sudo nginx -t
שרת האנטרהט צריך לאשר שהסינטקס עובד.
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
צעד 4. איתחול nginx
$ sudo nginx -s reload
אם קיבלתם הודעת שגיאה, משהו השתבש ואינכם מצליחים להמשיך עד אשר לבררו מדוע הדבר לא עבד.
צעד 5. בדיקת Onion-Location שלכם
כדי לבדוק אם Onion-Location פועל, קיראו ל HTTP headers, למשל:
$ wget --server-response --spider your-website.tld
חפשו את כניסת onion-location
ואת כתובת שרות הבצל.
או פיתחו את האתר לדפדפן Tor וקליפת סגולה תופיע לכם בסרגל הכתובות.
Caddy
תכונות Caddy automatic HTTPS כברירת מחדל, והם מספקים את תעודות ה TLS ומטפלים בניתוב מ HTTP-אל-HTTPS עבורכם. אם אתם משתמשים ב Caddy 2, כדי לכלול את Onion-Location header, הוסיפו את השורות הבאות בקובץ Caddyfile שלכם:
header Onion-Location http://<your-onion-address>.onion{path}
אם אתם מפעילים אתר סטטי עם כתובת הבצל ב $TOR_HOSTNAME
environment variable, קובץ Caddyfile שלכם יראה משכו כמו::
your-website.tld
header Onion-Location http://{$TOR_HOSTNAME}{path}
root * /var/www
file_server
Testing it out: Test it out with:
$ wget --server-response --spider your-website.tld
חפשו את כניסת onion-location
ואת כתובת שרות הבצל.
או פיתחו את האתר לדפדפן Tor וקליפת סגולה תופיע לכם בסרגל הכתובות.
שימוש ב HTML <meta>
attribute
ההתנהגות הזהה של Onion-Location iכוללת את האפשרות להגדיר אותו כתכונת HTML <meta>
http-equiv.
הדבר יכול להיות בשימוש אתרים אשר מעדיפים (או חייבים) להגדיר Onion-Location בעזרת הסבת תוכן שנתקבל כ HTML במקום להוסיף HTTP header חדש.
הOnion-Location header יהיה שקול ל <meta http-equiv="onion-location" content="http://<your-onion-service-address>.onion" />
שנתווסף לאלמנטHTML headשל דף האתר. החליפו את <your-onion-service-address.onion>
עם שרות הבצל אשר אתם מעונינים להעביר..
מידע נוסף
עיינו ב Onion-Location spec.