Drone.io 和 Github redirect_uri_mismatch
Drone.io with Github redirect_uri_mismatch
我正在尝试使用 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 应用详情:
redirct_url
不匹配的一个常见原因是无人机 运行 在反向代理(例如 nginx)后面,无法找出自己的地址来正确构建重定向 url。解决方案是设置 X-Forwarded-For
和 X-Forwraded-Proto
参数,让 Drone 确定自己的地址。
对于 nginx,从版本 0.6 开始,这是文档中推荐的 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;
}
}
我正在尝试使用 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 应用详情:
redirct_url
不匹配的一个常见原因是无人机 运行 在反向代理(例如 nginx)后面,无法找出自己的地址来正确构建重定向 url。解决方案是设置 X-Forwarded-For
和 X-Forwraded-Proto
参数,让 Drone 确定自己的地址。
对于 nginx,从版本 0.6 开始,这是文档中推荐的 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;
}
}