Drone.io与Github redirect_uri_mismatch

时间:2017-05-19 10:33:28

标签: github-api drone.io

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

错误:

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

docker-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 settings

1 个答案:

答案 0 :(得分:5)

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

对于nginx,从版本0.6开始,这是docs推荐的nginx配置[1]

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/