【问题标题】:Running Portainer in a Docker Container with Apache 2.4 mod_proxy and basic auth使用 Apache 2.4 mod_proxy 和基本身份验证在 Docker 容器中运行 Portainer
【发布时间】:2017-09-13 08:05:06
【问题描述】:

问:如何使用基本身份验证将 Apache 2.4 配置为 Portainer 的反向代理?

Portainer 是一个用于管理 Docker 容器的 UI。 Portainer 文档有一个示例 nginx configuration,但不幸的是没有 apache。

【问题讨论】:

    标签: apache user-interface docker reverse-proxy basic-authentication


    【解决方案1】:

    A:您需要使用标志 --no-auth 启动 Portainer 并使用 mod_proxy_wstunnel。

    使用 --no-auth 启动 Portainer。 我使用以下 Docker Compose 文件:

    portainer:
      image: portainer/portainer
      container_name: "portainer-app"
      privileged: true
      command: --no-auth
      ports:
        - 9000:9000
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /srv/docker/portainer/data:/data
        - /etc/localtime:/etc/localtime:ro
        - /etc/timezone:/etc/timezone:ro
      environment:
        TZ: "Europe/Berlin"
    

    为您的 Apache 域配置基本身份验证。 启用mod_proxy_wstunnel。 将以下内容添加到配置中:

    <Location /portainer/>
        ProxyPass http://localhost:9000/
        ProxyPassReverse http://localhost:9000/
        RequestHeader set Connection ""
    </Location>
    <Location /portainer/api/websocket/>
        RequestHeader set Upgrade $http_upgrade;
        RequestHeader set Connection "upgrade"
        ProxyPass ws://localhost:9000/api/websocket/
    </Location>
    

    【讨论】:

    • 这些设置主要对我有用,但不幸的是,我无法在 Portainer 中使用控制台功能。尝试使用控制台时,我的 apache 日志显示以下错误:AH01144: No protocol handler was valid for the URL /porttainer/api/websocket/exec。如果您使用的是 mod_proxy 的 DSO 版本,请确保代理子模块包含在使用 LoadModule 的配置中。有什么想法吗?
    【解决方案2】:

    我在 Docker Swarm 中安装了带有 Docker Flow Proxy 的 Portainer,都在 Apache 后面。

    按照this的想法,我能够成功配置apache。

    <Location /portainer/api/websocket/>
      RewriteEngine On
      RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
      RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
      RewriteRule /portainer/api/websocket/(.*) ws://192.168.1.190:480/portainer/api/websocket/$1 [P]
    </Location>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 2012-02-04
      • 2015-08-15
      • 1970-01-01
      • 2011-05-05
      相关资源
      最近更新 更多