AcrivityPubの一実装であるEpicyonサーバーを立ててみた。
Epicyon
EpicyonはActivityPubという規格に基づいて通信を行うSNSソフトウェアである。
ActivityPubを話すソフトウェアは互いに通信することができ、Mastodonなどと相互に通信ができる。
Epicyonは次のページにある。
https://epicyon.net/
特徴としては、JavaScriptを使っていないので、ページの動的な更新がされない、またリレーショナルデータベースなどを利用せず、データは普通のファイルとして保存されるそうだ。サーバーはPythonで書かれている。
インストールメモ
Epicyonのインストール
諸々入れる
sudo apt install python3-socks imagemagick python3-setuptools python3-cryptography python3-dateutil python3-idna python3-requests python3-flake8 python3-django-timezone-field python3-pyqrcode python3-png python3-bandit libimage-exiftool-perl certbot nginx wget
インストールの説明だとtorもインストールすることになってるけど省いた。
ソースコードとってくる
cd /opt
sudo git clone https://gitlab.com/bashrc2/epicyon
ユーザーの追加
sudo useradd -r -s /bin/false -d /opt/epicyon -U epicyon sudo chown -R epicyon:epicyon /opt/epicyon
なんかリンク張る。以降ドメインはepicyon.example.com
とする。
sudo mkdir /var/www/epicyon.example.com sudo mkdir -p /opt/epicyon/accounts/newsmirror sudo ln -s /opt/epicyon/accounts/newsmirror /var/www/epicyon.example.com sudo chown -R epicyon:epicyon /opt/epicyon/accounts/
accounts/
以下のownerがroot
になっていたので変更した。
デーモンを作成
sudo nano /etc/systemd/system/epicyon.service
公式ページの説明にあるように次のような内容を貼り付ける
[Unit] Description=epicyon After=syslog.target After=network.target [Service] Type=simple User=epicyon Group=epicyon WorkingDirectory=/opt/epicyon ExecStart=/usr/bin/python3 /opt/epicyon/epicyon.py --port 443 --proxy 7156 --domain epicyon.example.com -registration open --log_login_failures Environment=USER=epicyon Environment=PYTHONUNBUFFERED=true Restart=always StandardError=syslog CPUQuota=80% ProtectHome=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true ProtectKernelLogs=true ProtectHostname=true ProtectClock=true ProtectProc=invisible ProcSubset=pid PrivateTmp=true PrivateUsers=true PrivateDevices=true PrivateIPC=true MemoryDenyWriteExecute=true NoNewPrivileges=true LockPersonality=true RestrictRealtime=true RestrictSUIDSGID=true RestrictNamespaces=true SystemCallArchitectures=native [Install] WantedBy=multi-user.target
YOUR_DOMAINだけ使うドメイン(ここでは仮にepicyon.example.com
)に置換している。
ユーザー登録を無効化するにはExecStart
のところの--registration open
を--registration closed
に変更するといいっぽい。
有効化
sudo systemctl enable epicyon
sudo systemctl start epicyon
Webサーバーの設定
sudo nano /etc/nginx/sites-available/epicyon.example.com
公式の説明通りに次のような内容を貼り付ける。
server { listen 80; listen [::]:80; server_name epicyon.example.com; access_log /dev/null; error_log /dev/null; client_max_body_size 31m; client_body_buffer_size 128k; limit_conn conn_limit_per_ip 10; limit_req zone=req_limit_per_ip burst=10 nodelay; index index.html; rewrite ^ https://$server_name$request_uri? permanent; } server { listen 443 ssl; server_name epicyon.example.com; gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_min_length 1024; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css text/vcard text/vcard+xml application/json application/ld+json application/javascript text/xml application/xml application/rdf+xml application/xml+rss text/javascript; ssl_stapling off; ssl_stapling_verify off; #ssl on; ssl_certificate /etc/letsencrypt/live/epicyon.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/epicyon.example.com/privkey.pem; #ssl_dhparam /etc/ssl/certs/epicyon.example.com.dhparam; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; add_header Content-Security-Policy "default-src https:; script-src https: 'unsafe-inline'; style-src https: 'unsafe-inline'"; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always; access_log /dev/null; error_log /dev/null; index index.html; location /newsmirror { root /var/www/YOUR_DOMAIN; try_files $uri =404; } keepalive_timeout 70; sendfile on; location / { proxy_http_version 1.1; client_max_body_size 31M; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header X-Forward-Proto http; proxy_set_header X-Nginx-Proxy true; proxy_temp_file_write_size 64k; proxy_connect_timeout 10080s; proxy_send_timeout 10080; proxy_read_timeout 10080; proxy_buffer_size 64k; proxy_buffers 16 32k; proxy_busy_buffers_size 64k; proxy_redirect off; proxy_request_buffering off; proxy_buffering off; proxy_pass http://localhost:7156; tcp_nodelay on; } }
YOUR_DOMAINを使うドメイン(epicyon.example.com
)に置換している。
ssl on;
はwarning出たのでコメントアウトした。
これだけだとエラーでて動かないので、Nginxの設定を編集し
sudo nano /etc/nginx/nginx.conf
で、http
セクション内、include
の前に
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m; limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=50r/s;
とかを追加。
有効化
sudo ln -s /etc/nginx/sites-available/epicyon.example.com /etc/nginx/sites-enabled/
SSH対応
sudo systemctl stop nginx sudo certbot certonly -n --server https://acme-v02.api.letsencrypt.org/directory --standalone -d epicyon.example.com --renew-by-default --agree-tos --email test@example.com sudo systemctl start nginx
メールアドレスは適切に設定。
これで動き出すっぽい。
ダメな場合はNginxについてはsudo systemctl status nginx.service
やsudo journalctl -xeu nginx.service
などで、Epicyonについてはsudo journalctl -f -u epicyon
とかでログが見られるっぽい。
使う
これでブラウザからアクセスすると登録画面が出てきて使うことができる。
感想
WebクライアントのUIがこなれてない。デザインもあんまり分かりやすくないし、見た目もあんまりよくない気がする。
Mastodonとは通信ができたが、自分のメインのPleromaインスタンス(nixeneko.info)とはうまく疎通できなかった。Pleroma→Epicyonは配送できてもEpicyon→Pleromaは配送できなかった。Pleromaバージョンを上げればいいのかもしれないが…。
結局、試すには試したけど常用するには難しいかなという感じ。
さすがにWebクライアントが最新投稿を自動で取ってくるくらいはして欲しい気がする。とはいえ適当なアプリ使えばいいのかも。
自由ソフトウェア的な思想が結構強い雰囲気を感じる。好みは分かれるかもしれない。
特に、コミュニケーションを目的とせず、情報を配信するために自分でActivityPubサーバーを立てる時にはこういった選択肢は有用であると思われる。動かすのに強いマシンが要らないので。