mastdonサーバの構築φ(..)メモメモ
初めに読むもの(docker)
https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository
Docker🐳でMastodon🐘のインスタンスを立てるドン (リバースプロキシにnginx-proxy + letsencrypt-nginx-proxy-companionを使う)
Dockerインストール
Docker Community Edition for Ubuntu
Nginxのインストール
光の速さのWEBサーバー(nginx)をlet’s encryptでSSL化及びHTTP/2化。ついでにセキュリティ評価をA+にする。
NGINXについてまとめ(設定編)
[Mastodon]ConohaなCentos7にMastodonを建てる+α
documentation/Running-Mastodon/Production-guide.md
docker
非常に参考になるサイト
https://blog.potproject.net/archives/977
Gitのブランチ操作
初期の構築記
まず、以下のサイトを参照。
今何かと話題のマストドン(mastodon)鯖を自分用に無料で立てる方法
ここで、dockerを入れろというので、以下のページも参照し作業。
Get Docker for Ubuntu
リポジトリ登録までうまく行くが、docker-ceが無いと言われるので、Ubuntu17.04 docker-ceで検索し以下のページを見つける。
→ubuntuのVerが17.04だったので、標準ライブラリには無かったのが原因。
16.04であればうまくいった。
How to install Docker on Ubuntu 17.04
そこから、以下のページを見つける
v17.05.0-ce
ここから、以下のコマンドを実行。
curl -fsSL https://test.docker.com/ | sh
その後、今何かと話題のマストドン(mastodon)鯖を自分用に無料で立てる方法にもどり、以下のコマンドから再開。
sudo usermod -aG docker $USER
$ sudo su
# curl -L https://github.com/docker/compose/releases/download/1.12.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
.env.productionファイル修正の参考サイト。
トラブルシューティング等も、このサイトに記載されている。
DockerでMastodonをローカルで動かしてみた! ので、その方法をご紹介。
docker-compose run –rm web rails mastodon:confirm_email USER_EMAIL=strike.masa@gmail.com
#mastodonのビルド
$ docker-compose build
# Mastodonの起動(最初の一回だけ)
$ docker-compose up
# Mastodonの停止
$ docker-compose stop
# Mastodonの開始
$ docker-compose start
ユーザ登録(メール無しVer)
$ docker-compose run –rm web rails mastodon:confirm_email USER_EMAIL= メールアドレス
管理者への昇格
$ docker-compose run –rm web rails mastodon:make_admin USERNAME=ユーザネーム
参考サイト:
2017/04/15 ■ マストドン(Mastodon)おひとりさまインスタンスはじめました
Nginxの仮想ホストの定義ファイルの置く場所と、リンクの張り方
ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon
2台以上のサーバを公開する方法
Nginx でリバースプロキシサーバーつかってみる。Apache -> Nginx
Docker🐳でMastodon🐘のインスタンスを立てるドン (リバースプロキシにnginx-proxy + letsencrypt-nginx-proxy-companionを使う)
http://blog.akagi.jp/archives/3883.html
さくらのVPSで自分の MASTODON サーバを最速でつくる方法
UBUNTU SERVER 16.04でDOCKERを使わずにMASTODON構築
https://blog.apar.jp/linux/3619/
Let’s Encrypt で証明書を取得した時の手順備忘録
認証が通ったコマンドのサンプル
/opt/letsencrypt/certbot-auto certonly –force-renewal –webroot \
-w /usr/share/nginx/html -d yfmmastodon.dip.jp \
-m f.m.strike.masa@gmail.com \
–agree-tos
nginxの定義ファイル
server {
listen 80;
server_name yfmmstdn.mydns.jp;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
# proxy_pass http://192.168.1.3:3000;
proxy_pass http://localhost;
}
location ^~ /.well-known/ {
root /usr/share/nginx/html;
}
}
root@yfmmstdn:/etc/nginx/sites-available# cat yfmmastodon.dip.jp
map $http_upgrade $connection_upgrade {
default upgrade;
” close;
}
server {
listen 80;
listen [::]:80;
server_name yfmmastodon.dip.jp;
# Useful for Let’s Encrypt
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name yfmmastodon.dip.jp;
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_certificate /etc/letsencrypt/live/yfmmastodon.dip.jp/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/yfmmastodon.dip.jp/privkey.pem;
#ssl_dhparam /etc/ssl/certs/dhparam.pem;
keepalive_timeout 70;
sendfile on;
client_max_body_size 0;
root /home/mastodon/mastodon/public;
gzip on;
gzip_disable “msie6”;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
add_header Strict-Transport-Security “max-age=31536000”;
add_header Content-Security-Policy “style-src ‘self’ ‘unsafe-inline’; script-src ‘self’; object-src ‘self’; img-src data: https:; media-src data: https:; connect-src ‘self’ wss://yfmmastodon.dip.jp; upgrade-insecure-requests”;
location / {
try_files $uri @proxy;
}
location ~ ^/(assets|system/media_attachments/files|system/accounts/avatars) {
add_header Cache-Control “public, max-age=31536000, immutable”;
try_files $uri @proxy;
}
location @proxy {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy “”;
proxy_pass_header Server;
proxy_pass http://192.168.1.3:3000;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
tcp_nodelay on;
}
location /api/v1/streaming {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Proxy “”;
# proxy_pass http://localhost:4000;
proxy_pass http://192.168.1.3:4000;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
tcp_nodelay on;
}
error_page 500 501 502 503 504 /500.html;
}
mastodonのバックアップ等
Nginxのコマンド
起動
nginx
停止
nginx -s stop
再起動
nginx -s reload
設定ファイルのチェック
nginx -t
設定ファイルの場所
メインの設定ファイル
cd /etc/nginx/
各サーバー甩設定ファイル
cd /etc/nginx/conf.d/
mastodonの他サーバユーザをフォローする方法。
https://abikosan.com/mastodon_remote_follow
mastodonサーバのメンテ情報
dockerの最新安定板を持ってくるコマンド
curl -sSL https://get.docker.com/ | sh
インスタンスの削除
$ docker-compose down
$ rm -rf ./postgres
$ rm -rf ./redis
[備忘録]MASTODONアップデートの時のメモと注意
mastodon管理者昇格
docker-compose run --rm web rails mastodon:make_admin USERNAME=
Mastodon インスタンスのリモートフォローの仕組みと必要な購読更新の設定方法