Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Portainer in a Docker Container with Apache 2.4 mod_proxy and basic auth

Q: How do I configure Apache 2.4 as a reverse proxy for Portainer using Basic Authentication?

Portainer is a UI for managing Docker container. The Portainer documentation has a sample nginx configuration, but unfortunately none for apache.

like image 797
Arigion Avatar asked Jan 05 '23 04:01

Arigion


1 Answers

A: You need to start Portainer with the flag --no-auth and use mod_proxy_wstunnel.

Start Portainer with --no-auth. I use the following Docker Compose File:

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"

Configure Basic Authentication for your Apache domain. Enable mod_proxy_wstunnel. Add the following to the configuration:

<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>
like image 52
Arigion Avatar answered Jan 06 '23 18:01

Arigion