【问题标题】:Are the drone.io apache instructions out of date?drone.io apache 指令是否已过时?
【发布时间】:2018-08-16 02:31:59
【问题描述】:

Drone.io 0.8 的 release notes 说“请注意 grpc 使用 http/2 并且不能通过反向代理(即 nginx)进行路由。如果您使用的是 nginx,则必须绕过代理并直接与服务器。”但Apache setup instructions 使用“ProxyPassReverse”设置。

我认为这种不一致导致了这个错误:

user@host:~/drone $ docker-compose up
Recreating drone_drone-server_1

ERROR: for drone-server  Cannot start service drone-server: driver failed programming external connectivity on endpoint drone_drone-server_1 (30c01687260914ed6f3e3be7fab392a2dd8ea01e679dfe123e9faf9d6284e607):  (COMMAND_FAILED: '/sbin/iptables -w2 -t nat -A DOCKER -p tcp -d 0/0 --dport 9000 -j DNAT --to-destination 172.19.0.2:9000 ! -i br-b4723086fd08' failed: )
ERROR: Encountered errors while bringing up the project.

* 这是我的 ~/docker-compose.yaml:*

version: '2'

services:
  drone-server:
    image: drone/drone:0.8

    ports:
      - 8000:8000
      - 9000:9000
    volumes:
      - /var/lib/drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_ADMIN=gogs
      - DRONE_HOST=http://<hostname>:8000
      - DRONE_GOGS=true
      - DRONE_GOGS_URL=http://<hostname>:3000
      - DRONE_SECRET=${DRONE_SECRET}
      - DRONE_GOGS_SKIP_VERIFY=true

  drone-agent:
    image: drone/agent:0.8

    command: agent
    restart: always
    depends_on:
      - drone-server
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=drone-server:9000
      - DRONE_SECRET=${DRONE_SECRET}

* 我的 apache 文件 *

/etc/apache2/ports.conf

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-available/000-default.conf

Listen 80
Listen 8000
<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

/etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:8000>
        ProxyPreserveHost On

        #from docs.drone.io

        #Requestheader set X-Forwarded-Proto "https"

        #ProxyPass /ws/ ws://localhost:8000/ws/
        #ProxyPassReverse /ws/ ws://localhost:8000/ws/

        ProxyPass / http://127.0.0.1:8000/
        ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

所有这些都在树莓派 2 上运行

【问题讨论】:

    标签: docker-compose apache2 drone.io


    【解决方案1】:

    在您的情况下,8000 是普通的旧 http,而 9000 是 grpc。我希望 apache 代理能够按照您配置的方式为无人机 ui 端口 (8000) 工作。我会利用 docker-compose 的网络功能来允许服务器和代理都通过端口 9000 进行通信。

    类似这样的:

    version: '2'
    
    services:
      drone-server:
        image: drone/drone:0.8
    
        ports:
          - 8000:8000
          - 9000:9000
        volumes:
          - /var/lib/drone:/var/lib/drone/
        restart: always
        environment:
          - DRONE_OPEN=true
          - DRONE_ADMIN=gogs
          - DRONE_HOST=http://<hostname>:8000
          - DRONE_GOGS=true
          - DRONE_GOGS_URL=http://<hostname>:3000
          - DRONE_SECRET=${DRONE_SECRET}
          - DRONE_GOGS_SKIP_VERIFY=true
        networks
          - drone
    
      drone-agent:
        image: drone/agent:0.8
    
        command: agent
        restart: always
        depends_on:
          - drone-server
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
        environment:
          - DRONE_SERVER=drone-server:9000
          - DRONE_SECRET=${DRONE_SECRET}
        networks
          - drone     
    
       networks:
         drone:
    

    【讨论】:

    • 感谢您的帮助,但它仍然无法正常工作。我唯一的区别是我将网络放在全局级别,并且在无人机代理和无人机服务器的网络标签之后有“:”。我还将 替换为我的实际主机名(我相信这是正确的)。
    • 对不起,我忘记了端口 9000 的映射,我已经编辑了上面的 docker-compose
    【解决方案2】:

    此特定问题的原因是 docker 容器尝试使用的端口已在使用中。这是因为设置了restart: "always"according to the docs 意味着有错误的旧版本容器正在使用端口 9000 和 8000,从而阻止我的新容器使用它们。

    我通过 removing all old images and containers 修复了这个问题,然后运行 ​​sudo docker-compose up

    我仍然有这个问题。不幸的是,在调试 docker 的过程中,我以某种方式清除了我的 apache 服务器和 samba(网络计算机看不到它们),但这完全是一个不同的问题。因此,我的 docker-compose 脚本不能完全工作,但它不再告诉我端口已在使用中。现在看来问题是 Apache 不为 gogs 服务,所以无人机无法与它交谈。

    【讨论】:

      猜你喜欢
      • 2015-02-26
      • 2021-12-21
      • 2020-10-07
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 2021-10-06
      • 1970-01-01
      • 2015-08-29
      相关资源
      最近更新 更多