123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Running Traefik - HTTP Reverse Proxy and Load Balancer - in Docker</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="Docker Made Easy,Home Lab,Home Lab Ideas,Install Guide,Self-Hosted,Container,Containerization,Containerize,Docker,Docker Container,Docker How To,Docker Installation Tutorial,Docker Made Simple,Docker Simplified,Traefik,Reverse Proxy,HTTP Proxy,Ubuntu,Linux,Getting Started With Docker,Docker Tutorial,How To,Tutorial,i12bretro">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Running Traefik - HTTP Reverse Proxy and Load Balancer - in Docker">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="revised" content="07/08/2022 08:23:25 PM" />
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Running Traefik - HTTP Reverse Proxy and Load Balancer - in Docker</h1>
- </div>
- <div></div>
- <div id="content">
- <h2>What is Traefik?</h2>
- <blockquote><em>Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components [...] and configures itself automatically and dynamically. Pointing Traefik at your orchestrator should be the only configuration step you need. -<a href="https://github.com/traefik/traefik" target="_blank">https://github.com/traefik/traefik</a></em></blockquote>
- <h2>Installing Docker</h2>
- <ol>
- <li>Log into the Linux based device</li>
- <li>Run the following commands in the terminal
- <div class="codeBlock"># install prerequisites<br />
- sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y<br />
- # add docker gpg key<br />
- curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -<br />
- # add docker software repository<br />
- sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"<br />
- # install docker<br />
- sudo apt install docker-ce docker-compose containerd.io -y<br />
- # enable and start docker service<br />
- sudo systemctl enable docker && sudo systemctl start docker<br />
- # add the current user to the docker group<br />
- sudo usermod -aG docker $USER<br />
- # reauthenticate for the new group membership to take effect<br />
- su - $USER</div>
- </li>
- </ol>
- <h2>Running Traefik</h2>
- <ol>
- <li>Continue with the following commands in a terminal window
- <div class="codeBlock"># create a working directory<br />
- mkdir ~/docker/traefik -p<br />
- # create and edit config file<br />
- nano ~/docker/traefik/traefik.yml</div>
- </li>
- <li>Paste the following default configuration into traefik.yml, replacing the hostname with the docker host
- <p>## traefik.yml</p>
- <p># Docker configuration backend<br />
- providers:<br />
- docker:<br />
- defaultRule: "Host(`{{ trimPrefix `/` .Name }}.<% dockerhost.fqdn %>`)"</p>
- <p># API and dashboard configuration<br />
- api:<br />
- insecure: true</p>
- </li>
- <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
- <li>Continue with the following commands in a terminal window
- <div class="codeBlock"># start the traefik container<br />
- docker run -d --name=traefik -p 8080:8080 -p 80:80 -v ~/docker/traefik/traefik.yml:/etc/traefik/traefik.yml -v /var/run/docker.sock:/var/run/docker.sock traefik</div>
- </li>
- <li>Open a web browser and navigate to http://DNSorIP:8080</li>
- <li>Welcome to the Traefik web dashboard</li>
- </ol>
- <h2>Dynamic Container Ingress Testing</h2>
- <ol>
- <li>Continue with the following commands in a terminal window
- <div class="codeBlock"># start a basic whoami web service<br />
- docker run -d --name whoami -p 40001:80 traefik/whoami</div>
- </li>
- <li>Back in the web browser, navigate to whoami.<% docker host %></li>
- <li>The Apache HTTPD server response should be displayed</li>
- <li>Back in the Traefik dashboard the new whoami HTTP router should display</li>
- <li>Let's try one more test
- <div class="codeBlock"># create an apache2 working directory<br />
- mkdir ~/docker/apache2/htdocs -p<br />
- # create a test html file<br />
- echo '<html><body><h1>Hello world</h1><h3>Have you subscribed yet?</h3></body></html>' > ~/docker/apache2/htdocs/index.html<br />
- # start a basic apache httpd server<br />
- docker run -d --name httpd -p 40002:80 -v ~/docker/apache2/htdocs:/usr/local/apache2/htdocs/ httpd</div>
- </li>
- <li>Back in the web browser, navigate to httpd.<% docker host %></li>
- <li>The Apache HTTPD server response should be displayed</li>
- <li>Back in the Traefik dashboard the new httpd HTTP router should display</li>
- </ol>
- <p>Documentation: <a href="https://doc.traefik.io/traefik/" target="_blank">https://doc.traefik.io/traefik/</a></p> </div>
- </div>
- </body>
- </html>
-
|