1

我正在尝试使用 Github 设置 Drone CI 0.6。但是我不断收到 oauth 错误。也许有人可以指出我做错了什么。我已经尝试过 with 和 without DRONE_HOST,但它总是说不匹配。

错误:

无法验证用户。redirect_uri_mismatch redirect_uri 必须与此应用程序的注册回调 URL 匹配。 https://developer.github.com/v3/oauth/#redirect-uri-mismatch

码头工人-compose.yml :

version: '2'

services:
  drone-server:
    image: drone/drone:0.6
    ports:
      - 8822:8000
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_HOST=http://ci.rallabs.com
      - DRONE_GITHUB=true
      - DRONE_GITHUB_CLIENT=myGithubClient
      - DRONE_GITHUB_SECRET=myGithubSecret
      - DRONE_SECRET=mySecret
  drone-agent:
    image: drone/drone:0.6
    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=ws://drone-server:8000/ws/broker
      - DRONE_SECRET=mySecret

Github 应用详情:

Github 设置

4

1 回答 1

5

不匹配的一个常见原因redirct_url是因为drone在反向代理(例如nginx)后面运行并且无法找出自己的地址来正确构造重定向url。解决这个问题的方法是设置X-Forwarded-ForX-Forwraded-Proto参数,让 Drone 确定自己的地址。

对于 nginx,从 0.6 版开始,这是文档 [1] 中推荐的 nginx 配置

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

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

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

        proxy_pass http://127.0.0.1:8000;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_buffering off;

        chunked_transfer_encoding off;
    }

    location ~* /ws {
        proxy_pass http://127.0.0.1:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
    }
}

[1] http://docs.drone.io/setup-with-nginx/

于 2017-05-21T20:11:54.513 回答