banner
老孙

老孙博客

资深网民孙先生
mastodon
email

使用Docker部署Activity-Relay服務

  • 經過測試國內部署會有無法通訊的問題。

測試環境#

centos7.9

準備工作#

  • git
  • openssl
  • nginx
  • docker
  • docker-compose

從倉庫 Pull a repository#

git clone https://github.com/yukimochi/Activity-Relay.git -b v2.0.0

複製編輯 config.yml#

進入Activity-Relay目錄

cd Activity-Relay
cp config.yml.example config.yml

修改相關配置

vim config.yml

生成 actor RSA 證書 ./actor.pem#

ubuntu 使用

openssl genrsa -traditional | tee actor.pem

centos 使用

openssl genrsa -out actor.pem 1024 | tee actor.pem

賦予權限 600

chmod 600 actor.pem

構建鏡像與運行服務#

docker-compose build
docker-compose up -d

查看容器運行狀態#

docker-compose ps

停止服務#

docker-compose down

相關參考#

docker-compose 配置

version: "2.3"
services:
  redis:
    restart: always
    image: redis:alpine
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
    volumes:
      - "./redisdata:/data"

  worker:
    container_name: worker
    build: .
    image: yukimochi/activity-relay
    working_dir: /var/lib/relay
    restart: always
    init: true
    command: relay worker
    volumes:
      - "./actor.pem:/var/lib/relay/actor.pem"
      - "./config.yml:/var/lib/relay/config.yml"
    depends_on:
      - redis

  server:
    container_name: relay
    build: .
    image: yukimochi/activity-relay
    working_dir: /var/lib/relay
    restart: always
    init: true
    ports:
      - "8080:8080"
    command: relay server
    volumes:
      - "./actor.pem:/var/lib/relay/actor.pem"
      - "./config.yml:/var/lib/relay/config.yml"
    depends_on:
      - redis

Nginx 設置

upstream relay {
    server 127.0.0.1:8080;
  }
  server {
    server_name relay.example.com;

    location / {
      root /var/lib/relay;
      try_files $uri $uri/index.html =404;
    }

    location /inbox {
      rewrite ^/inbox(.*) /$1 break;
      proxy_pass http://relay/;
      proxy_pass_request_headers on;
      proxy_set_header Host $http_host;
    }

    location /actor {
      rewrite ^/inbox(.*) /$1 break;
      proxy_pass http://relay/;
      proxy_pass_request_headers on;
      proxy_set_header Host $http_host;
    }

  }

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。