Register drone-agent with remote drone-server

请问我该如何编写 nginx 配置,才能向远程drone-server注册drone-agent?
— translate —
How can I write nginx configuration to register drone-agent with remote drone-server?

remote docker-compose.yml

  drone-server:
    container_name: drone-server
    image: drone/drone:0.8
    restart: always
    mem_limit: 512m
    cpu_shares: 10
    hostname: drone-server
    volumes:
      - ../dev-ops-repo/drone-server:/var/lib/drone/
    environment:
      - DRONE_OPEN=false
      - DRONE_HOST=http://drone.haitanyule.com
      - DRONE_SECRET=xxx
      - DRONE_ADMIN=xxx
      - DRONE_GOGS=true
      - DRONE_GOGS_URL=http://git.haitanyule.com
      - DRONE_GOGS_GIT_USERNAME=xxx
      - DRONE_GOGS_GIT_PASSWORD=xxx
      - DRONE_GOGS_PRIVATE_MODE=true

remote nginx.conf

server {
    listen       80;
    server_name  drone.haitanyule.com;

    location / {
        proxy_pass http://drone-server:8000/;

        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;

        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_buffering off;

        chunked_transfer_encoding off;
    }
}

local docker-compose.yml

drone-agent:
    container_name: drone-agent
    image: drone/agent:0.8
    restart: always
    mem_limit: 512m
    cpu_shares: 10
    hostname: drone-agent
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server.haitanyule.com:80
      - DRONE_SECRET=xxx
    command: agent

You need to expose the drone server port so nginx can reach it. So in the remote docker-compose.yml, add:

drone-server:
  [...]
  ports:
    - 8000:8000

You should probably try the new 1.0 RC version. It uses HTTP instead of GRPC for agent communication.

:slight_smile: 我已经用Traefik解决Drone 0.8的GRPC了。并且现在在试用Drone 1.0.0-rc.1了。
— translate —
I have used Traefik to solve the GRPC of Drone 0.8.And now I am trying out Drone 1.0.0-rc.1.