Browse Source

0758: Running Traefik - HTTP Reverse Proxy and Load Balancer - in Docker

i12bretro 2 years ago
parent
commit
9418ebd0cf
1 changed files with 108 additions and 0 deletions
  1. 108 0
      0758.html

+ 108 - 0
0758.html

@@ -0,0 +1,108 @@
+    <!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&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release)/gpg | sudo apt-key add -<br />
+	# add docker software repository<br />
+	sudo add-apt-repository &quot;deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F&#39;=&#39; &#39;/^ID=/{ print $NF }&#39; /etc/os-release) $(lsb_release -cs) stable&quot;<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 &amp;&amp; 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: &quot;Host(`{{ trimPrefix `/` .Name }}.&lt;% dockerhost.fqdn %&gt;`)&quot;</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.&lt;% docker host %&gt;</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&#39;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 &#39;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello world&lt;/h1&gt;&lt;h3&gt;Have you subscribed yet?&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;&#39; &gt; ~/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.&lt;% docker host %&gt;</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>
+