--- title: Docker部署Activity-Relay服务 tags: Docker categories: 分享 abbrlink: 57ea9005 date: 2023-10-03 09:06:40 cover: --- ## 准备工作 - 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; } } ```