Admin interface redirects to gitea

Hi, I’m currently trying to setup drone in a local environment. Every time I try to access the admin interface, I get redirected to gitea with “Unregistered Redirect URI” as error message.

version: '3'

services:
  gitea:
    image: gitea/gitea:latest
    container_name: gitea-app
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - ROOT_URL=http://gitea.localhost
      - SSH_DOMAIN=gitea.localhost
    restart: always
    volumes:
      - ./data:/data
    ports:
      - "22:22"
    networks:
      - webproxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.gitea.rule=Host(`gitea.localhost`)
      - traefik.http.routers.gitea.entrypoints=web
      - traefik.http.services.gitea.loadbalancer.server.port=3000

  drone-server:
    image: drone/drone:latest
    container_name: drone-server
    volumes:
      - ./drone:/var/lib/drone/
    restart: always
    depends_on:
      - gitea
    environment:
      DRONE_GITEA_SERVER: http://gitea.localhost
      DRONE_GITEA_CLIENT_ID: "286cd719-179f-464f-bd29-efff23aea50e"
      DRONE_GITEA_CLIENT_SECRET: "Dri51-9sq-6gnY7NzzPh_-nLfpQVxoZgIRyTa05uaS8="
      DRONE_RPC_SECRET: e2c83aef9fc2acafeaa0ee4931648efd
      DRONE_SERVER_HOST: http://drone.localhost
      DRONE_SERVER_PROTO: http
      DRONE_USER_CREATE: username:root,machine:false,admin:true,token:55f24eb3d61ef6ac5e83d550178638dc
    networks:
      - webproxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.drone-server.rule=Host(`drone.localhost`)
      - traefik.http.routers.drone-server.entrypoints=web
      - traefik.http.services.drone-server.loadbalancer.server.port=80

  drone-runner:
    image: drone/drone-runner-docker:1
    container_name: drone-runner
    networks:
      - webproxy
    environment:
      DRONE_RPC_HOST: drone-server
      DRONE_RPC_PROTO: http
      DRONE_RPC_SECRET: e2c83aef9fc2acafeaa0ee4931648efd
      DRONE_RUNNER_CAPACITY: 2
      DRONE_RUNNER_NAME: 'gitea-runner'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock


networks:
  webproxy:
    external: true

Even if I removed the labels and use directly the ports, drone redirects me to gitea.

What am I missing?

Hi, I’m currently trying to setup drone in a local environment. Every time I try to access the admin interface, I get redirected to gitea with “Unregistered Redirect URI” as error message.

This error message would indicate that you configured a Gitea oauth2 application (in the Gitea user interface) and you specified an incorrect redirect uri. The redirect uri configured in Gitea must exactly match ${DRONE_SERVER_PROTO}://${DRONE_SERVER_HOST}/login (replace variables with actual values)

1 Like

Ah, got it. My fault was to add http:// into DRONE_SERVER_HOST … however, I ran into another issue.

Login Failed. Post “http://gitea.localhost/login/oauth/access_token”: dial tcp: lookup gitea.localhost on 127.0.0.11:53: no such host

This message came right after I allowed the permission for the OAuth app

It sounds like a container network / dns problem. When you have multiple containers on separate networks you need to make sure they can talk to one another at the specified hostname. Unfortunately I cannot provide help with general networking / dns issues since this is outside my area of expertise.

Ofc. and I understand that. But I also got a similar error when I’m not using any different network/container to mange things here.

version: '3.7'

services:
  gitea:
    image: gitea/gitea:latest
    container_name: gitea-app
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - ROOT_URL=http://localhost:3000
      - SSH_DOMAIN=127.0.0.1
    restart: always
    volumes:
      - ./data:/data
    ports:
      - '22:22'
      - '3000:3000'
#    networks:
#      - gitea
  drone-server:
    image: drone/drone:latest
    ports:
      - '3001:80'
      - '443:443'
#    networks:
#      - gitea
    environment:
      DRONE_GITEA_SERVER: http://localhost:3000
      DRONE_GITEA_CLIENT_ID: 9e1187bf-8571-4b49-9c32-8a46767d59b1
      DRONE_GITEA_CLIENT_SECRET: P6AotQZoGP4LVq4q_pyLjwc8EPwlAT4Jq4x1UVGgZHM=
      DRONE_RPC_SECRET: e2c83aef9fc2acafeaa0ee4931648efd
      DRONE_SERVER_HOST: localhost:3001
      DRONE_SERVER_PROTO: http
      DRONE_USER_CREATE: username:root,machine:false,admin:true,token:55f24eb3d61ef6ac5e83d550178638dc
    volumes:
      - ./drone:/data

#networks:
#  gitea:
#    external: false

Login Failed. Post “http://localhost:3000/login/oauth/access_token”: dial tcp 127.0.0.1:3000: connect: connection refused

I mean this is a very very basic docker-compose file, and I don’t think that I missed something(?)

You cannot use localhost to communicate across containers:

localhost always (every platform, every Docker setup) refers to the container itself and never to anything running in any other container or the host system. (Unless you’re running a container with --net host , which is odd on Docker for Mac.)

Please see the following thread:

If you continue to have issues with docker-compose networking, I recommend using the docker forum and engaging docker support. We are happy to answer general Drone questions and provide support for Drone, but we cannot provide general networking or general docker-compose support.

I was able to fix the problem by creating static IPs for each service in the network and modifying the hosts file.

Have a nice day and thank you both for your help.