
* fix relrefs around trends and related entities * revert moving caption-links to middle of page * hide empty menu in table of contents * clarify edit notifs are only for boosted statuses * following/followers no longer need auth * fix typo * specify cooldown period for account Move * use the correct cooldown * add missing parameters to accounts/id/statuses * link to account_statuses_filter.rb * fix typo (#1072) * fix typo (#1073) * fix link to http sig spec (#1067) * simply HTTP request examples in api methods docs * add missing client_secret to oauth/token (#1062) * Add any, all, none to hashtag timeline * minor formatting changes * Update signature requirements and advice * fix public key -> private key * clarify use of RSA with SHA256 * Add note about saving your profile after adding rel-me link * v2 filters api * comment out params that shouldn't be used in v2 filter api * admin trends * remove old todo * canonical email blocks + scheduled statuses * remove under-construction warnings from finished pages * verify api method params with source code * fix typo (#1088) * fix broken caption-links (#1100) * fix formatting of entities (#1094) * Remove keybase section from user guide (#1093) * fix typos (#1092) * Verify limits are accurate (#1086) * add mention of iframe limitation (#1084) * Add CORS header to WEB_DOMAIN example (#1083) * Fix typo (#1081) * pin http sigs spec at draft 8 * Revert "pin http sigs spec at draft 8" This reverts commit 9fd5f7032b69b29e77599dd62adfe8d2f5cd4f20. * add case sensitivity warning to 4.0 roles * Add url length note to bio (#1087) * remove follow scope from examples (#1103) * clarify usage of update_credentials to update profile fields * add noindex to Account entitity * remove required hint from technically not required property
5.1 KiB
title | description | menu | ||||||
---|---|---|---|---|---|---|---|---|
匿名服务 | 通过TOR的匿名服务来访问Mastodon。 |
|
可以通过TOR的匿名服务来访问Mastodon。这将给你一个只能通过 TOR 网络连接的 *.onion 地址。
安装 Tor
首先,Tor的Debian软件仓库需要被添加至apt中。
deb https://deb.torproject.org/torproject.org stretch main
deb-src https://deb.torproject.org/torproject.org stretch main
接下来,添加相应gpg密钥。
curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -
最后,安装所需软件包。
apt install tor deb.torproject.org-keyring
配置 Tor
编辑 /etc/tor/torrc
并添加如下设置。
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServiceVersion 3
HiddenServicePort 80 127.0.0.1:80
重启 tor。
sudo service tor restart
现在,你的tor域名可以在 /var/lib/tor/hidden_service/hostname
找到。
移动你的Mastodon配置
我们将需要将你的Mastodon配置告诉Nginx两次。为了不自我重复(DRY),我们需要将Mastodon配置移动到一个可被引用的独立文件。
在 /etc/nginx/snippets/mastodon.conf
创建一个新文件。放入除listen
、server_name
、include
及所有SSL相关选项之外的所有配置参数至新文件中。你的新文件看起来可能像这样。
add_header Referrer-Policy "same-origin";
keepalive_timeout 70;
sendfile on;
client_max_body_size 80m;
root /home/mastodon/live/public;
…
error_page 500 501 502 503 504 /500.html;
access_log /var/log/nginx/mastodon_access.log;
error_log /var/log/nginx/mastodon_error.log warn;
替换你的旧Mastodon配置文件,在新配置文件中添加一个include指令。
你的Nginx配置文件将看起来像这样。
server {
listen 80;
server_name mastodon.myhosting.com;
return 301 https://$server_name$request_uri;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
list [::]:443 ssl http2;
server_name mastodon.myhosting.com;
include /etc/nginx/snippets/mastodon.conf;
ssl_certificate /etc/letsencrypt/live/mastodon.myhosting.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mastodon.myhosting.com/privkey.pem;
}
通过http提供Tor服务
尽管通过https提供你的Tor版Mastodon可能很诱人,但对大多数人来说这不是一个好主意。请参阅Tor Project上的这篇博文,了解为什么https证书无法增加价值。由于你无法获得onion域名的SSL证书,当你尝试使用你的Mastodon时还会被证书错误所困扰。最近,一位Tor开发者在这里阐述了为什么通过https提供Tor服务对大多数用例都没有好处的原因。
解决方法是通过http提供你的Mastodon服务,但仅供Tor使用。这可以通过在Nginx配置文件中添加额外的设置来完成。
server {
listen 80;
server_name mastodon.qKnFwnNH2oH4QhQ7CoRf7HYj8wCwpDwsa8ohJmcPG9JodMZvVA6psKq7qKnFwnNH2oH4QhQ7CoRf7HYj8wCwpDwsa8ohJmcPG9JodMZvVA6psKq7.onion;
include /etc/nginx/snippets/mastodon.conf;
}
server {
listen 80;
server_name mastodon.myhosting.com;
return 301 https://$server_name$request_uri;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
list [::]:443 ssl http2;
server_name mastodon.myhosting.com;
include /etc/nginx/snippets/mastodon.conf;
ssl_certificate /etc/letsencrypt/live/mastodon.myhosting.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mastodon.myhosting.com/privkey.pem;
}
用你位于 /var/lib/tor/hidden_service/hostname
文件中的长hash替换上文中提供的。
请注意,onion域名已经被附加了“mastodon.”前缀。你的Tor地址充当通配符域名。所有的子域名都将被路由,你可以配置你的Nginx来响应你想要的任何子域名。如果你不想在你的tor域名上托管任何其他服务,你可以省略子域名,或者选择一个不同的子域名。
这里,你就可以看出移动你的mastodon配置到不同文件的好处了。如果不移动的话,你的所有配置都必须粘贴至两个地方,任何对你配置的改动你都必须同时修改两个地方。
重启你的Web服务器。
service nginx restart
陷阱
你需要注意一些事情。某些重定向会将你的用户跳转至https。他们必须手动把URL替换成http才能继续。
许多的资源,诸如图片,将仍然从常规非Tor域名加载。问题的严重性很大程度上取决于用户的谨慎程度。
{{< translation-status-zh-cn raw_title="Hidden services" raw_link="/admin/optional/tor/" last_tranlation_time="2020-05-04" raw_commit="ad1ef20f171c9f61439f32168987b0b4f9abd74b">}}