CloudReports
  • Home
  • Linux
  • Web development
  • Javascript
  • SQL
  • Ant Design tutorial
  • QR Code Scanner
No Result
View All Result
  • Home
  • Linux
  • Web development
  • Javascript
  • SQL
  • Ant Design tutorial
  • QR Code Scanner
No Result
View All Result
CloudReports
No Result
View All Result
Home Web development

Install portainer + traefik on Ubuntu

npn by npn
April 4, 2020
in Web development
Reading Time: 3 mins read
0
Install portainer + traefik on Ubuntu
635
VIEWS
Share on FacebookShare on Twitter

Contents

  • 1 Install portainer + traefik on Ubuntu 16.04
    • 1.1 1. Install docker
    • 1.2 2. Install docker-compose
    • 1.3 3. Install traefik
    • 1.4 4. Install portainer
Rate this post

Install portainer + traefik on Ubuntu 16.04

1. Install docker

https://docs.docker.com/install/linux/docker-ce/ubuntu/

2. Install docker-compose

https://docs.docker.com/compose/install/

3. Install traefik

3.1 First, create a directory for our containers:

ADVERTISEMENT
mkdir -p /opt/containers/{traefik,portainer}

3.2 Create the data folder and config files for Traefik:

mkdir -p /opt/containers/traefik/data
touch /opt/containers/traefik/data/acme.json
chmod 600 /opt/containers/traefik/data/acme.json
touch /opt/containers/traefik/data/traefik.yml

3.3 Create the basic Traefik configuration file:

location: /opt/containers/traefik/data/traefik.yml

api:
  dashboard: true

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

certificatesResolvers:
  http:
    acme:
      email: [email protected]
      storage: acme.json
      httpChallenge:
        entryPoint: http

3.4 Setup Traefik

Create traefik network

docker network create proxy

Generate traefik basic auth information (1)

sudo apt-get install apache2-utils
echo $(htpasswd -nbB yourUserName yourPassword) | sed -e s/\\$/\\$\\$/g

Create Traefik Docker Compose file: replace USER:PASSWORD with generated value above (1)

location: /opt/containers/traefik/docker-compose.yml

version: '3'

services:
  traefik:
    image: traefik:v2.0
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data/traefik.yml:/traefik.yml:ro
      - ./data/acme.json:/acme.json
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.traefik.entrypoints=http'
      - 'traefik.http.routers.traefik.rule=Host(`traefikdomain.local`)'
      - 'traefik.http.middlewares.traefik-auth.basicauth.users=USER:PASSWORD'
      - 'traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https'
      - 'traefik.http.routers.traefik.middlewares=traefik-https-redirect'
      - 'traefik.http.routers.traefik-secure.entrypoints=https'
      - 'traefik.http.routers.traefik-secure.rule=Host(`traefikdomain.local`)'
      - 'traefik.http.routers.traefik-secure.middlewares=traefik-auth'
      - 'traefik.http.routers.traefik-secure.tls=true'
      - 'traefik.http.routers.traefik-secure.tls.certresolver=http'
      - '[email protected]'

networks:
  proxy:
    external: true

replace traefikdomain.local with your domain for traefik

Start traefik

cd /opt/containers/traefik
docker-compose up -d

browse traefikdomain.local to check the traefik manage page

4. Install portainer

Create portainer docker-compose file

location: /opt/containers/portainer/docker-compose.yml

version: '3'

services:
  portainer:
    image: portainer/portainer:latest
    container_name: portainer
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./data:/data
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.portainer.entrypoints=http"
      - "traefik.http.routers.portainer.rule=Host(`portainerdomain.local`)"
      - "traefik.http.middlewares.portainer-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.portainer.middlewares=portainer-https-redirect"
      - "traefik.http.routers.portainer-secure.entrypoints=https"
      - "traefik.http.routers.portainer-secure.rule=Host(`portainerdomain.local`)"
      - "traefik.http.routers.portainer-secure.tls=true"
      - "traefik.http.routers.portainer-secure.tls.certresolver=http"
      - "traefik.http.routers.portainer-secure.service=portainer"
      - "traefik.http.services.portainer.loadbalancer.server.port=9000"
      - "traefik.docker.network=proxy"

networks:
  proxy:
    external: true

replace portainerdomain.local with your domain for portainer

Start portainer

cd /opt/containers/portainer
docker-compose up -d

browse portainerdomain.local for portainer web control panel

Tags: install portainer ubuntuinstall traefik portainerinstall traefik ubuntu
Previous Post

The evolution of front-end development

Next Post

Antd Basic – Initialize React project using Umi

npn

npn

Next Post
Antd Basic – Initialize React project using Umi

Antd Basic - Initialize React project using Umi

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Categories

  • Android (1)
  • Ant Design tutorial (7)
  • App/Game (2)
  • Javascript (16)
  • Layout and Routing (2)
  • Linux (9)
  • PC & LAPTOP (6)
  • PERSONAL FINANCES (1)
  • React (13)
  • SQL (2)
  • TECHNOLOGY & DIGITAL (7)
  • The Basics (5)
  • Web development (37)

Search

No Result
View All Result
  • About Us
  • Documentation
Together We Learn!

© 2021 Cloudreports - Developer ideas, tips and stories...

No Result
View All Result
  • Home
  • Linux
  • Web development
  • Javascript
  • SQL
  • Ant Design tutorial
  • QR Code Scanner

© 2021 Cloudreports - Developer ideas, tips and stories...