<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Reverse Proxy Archives - Nerd Corner</title>
	<atom:link href="https://nerd-corner.com/tag/reverse-proxy-en/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerd-corner.com/tag/reverse-proxy-en/</link>
	<description>Craft your dreams!</description>
	<lastBuildDate>Sun, 16 Mar 2025 18:49:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://nerd-corner.com/wp-content/uploads/2019/10/cropped-LogoNerdCorner-2-32x32.png</url>
	<title>Reverse Proxy Archives - Nerd Corner</title>
	<link>https://nerd-corner.com/tag/reverse-proxy-en/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Deployment of a WebApp with Kubernetes and Caddy</title>
		<link>https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/</link>
					<comments>https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/#respond</comments>
		
		<dc:creator><![CDATA[Nerds]]></dc:creator>
		<pubDate>Sun, 16 Feb 2025 18:31:48 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[App development]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[Caddy]]></category>
		<category><![CDATA[Caddy Server]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[ClusterIP]]></category>
		<category><![CDATA[ConfigMap]]></category>
		<category><![CDATA[Container]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Docker]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[Domain Registration]]></category>
		<category><![CDATA[Hetzner]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Ingress]]></category>
		<category><![CDATA[Ingress Controller]]></category>
		<category><![CDATA[ip addres]]></category>
		<category><![CDATA[K3s]]></category>
		<category><![CDATA[Kubectl]]></category>
		<category><![CDATA[Kubernetes]]></category>
		<category><![CDATA[LoadBalancer]]></category>
		<category><![CDATA[mySql]]></category>
		<category><![CDATA[Nest.js]]></category>
		<category><![CDATA[Node Port]]></category>
		<category><![CDATA[Pods]]></category>
		<category><![CDATA[Redis]]></category>
		<category><![CDATA[Reverse Proxy]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Service]]></category>
		<category><![CDATA[Step by step guide]]></category>
		<category><![CDATA[Traefik]]></category>
		<guid isPermaLink="false">https://nerd-corner.com/de/?p=1695</guid>

					<description><![CDATA[<p>After describing how to create production-ready Docker images and upload them to Docker Hub in the last article, it is now time to make these &#8230; </p>
<p>The post <a href="https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/">Deployment of a WebApp with Kubernetes and Caddy</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>After describing how to create production-ready Docker images and upload them to Docker Hub in the last article, it is now time to make these images available on a server. The aim is to make the web application accessible to everyone via a dedicated domain. To do this, we use a virtual private server (VPS) from Hetzner and deploy Kubernetes (k3s) with Caddy as a reverse proxy.</p>
<p><strong><em>You might also be interested in this: </em></strong><a href="https://nerd-corner.com/create-docker-images-and-upload-them-to-docker-hub/"><em>Create Docker images and upload them to Dockerhub</em></a></p>
<h2>Set up a VPS with Hetzner</h2>
<p>Hetzner often offers referral links with credit benefits for new customers. Of course, you can also use other providers, but Hetzner is attractively priced and offers solid services.</p>
<h3>What is a VPS?</h3>
<p>A Virtual Private Server (VPS) is a virtual server that is operated on a physical machine and acts as an independent server. It offers more control than classic shared hosting and is a cost-effective alternative to dedicated servers. Access is usually via SSH (Secure Shell), which allows us to control the server via the command line.</p>
<h3>SSH access to the VPS</h3>
<p>Once a VPS has been created, it is usually managed via a secure shell (SSH). SSH is a protocol that enables encrypted connections to remote servers. The following command is used to connect to the server:</p>
<p data-start="1137" data-end="1384"><span style="background-color: #e9ebec; color: #222222; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-size: 15px;">ssh root@&lt;IP-Server&gt;</span></p>
<p>If an SSH key has been stored, authentication can be carried out using public key authentication, which is more secure than a password.</p>
<h3>Create a server at Hetzner</h3>
<ol>
<li>After logging into the Hetzner Cloud, we navigate to “Projects” and create a new project.</li>
<li>Select “Add server” and can configure an instance.</li>
<li>The cheapest model is often sufficient to start with. However, I recommend activating the option for an IPv4 address, as purely IPv6-based setups often cause compatibility problems.</li>
</ol>
<h3>Setting up a domain</h3>
<p>To access the application later under your own domain, you must register a domain and link it to the server.</p>
<h3>Apply for a domain at Hetzner</h3>
<ol>
<li>Register a new domain or add an existing domain in the Hetzner ConsoleH.</li>
<li>To manage DNS entries, we need to activate DNS access.</li>
</ol>
<h3>Set name servers</h3>
<p>The following name servers should be used:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">helium.ns.hetzner.de. 
hydrogen.ns.hetzner.com. 
oxygen.ns.hetzner.com.</pre>
<p>These new name servers offer better performance and flexibility compared to the old Hetzner name servers:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">ns1.first-ns.de.
robotns2.second-ns.de.
robotns3.second-ns.com.</pre>
<p>However, both nameserver variants are possible! The DNS changes take some time. However, we can use tools such as MXToolbox to check whether the changes have already taken place.</p>
<h3>Connect the domain to the server</h3>
<p>Now the IP address of the server must be linked to the domain:</p>
<ol>
<li>Switch to DNS zones in the Hetzner Cloud.</li>
<li>Select the registered domain.</li>
<li>Create a new A-Record and enter the IPv4 address of the server.</li>
<li>If available, remove the IPv6 record (AAAA) to avoid compatibility problems.</li>
</ol>
<p>You can also use <a href="http://mxtoolbox.com">MXToolbox</a> to check whether the DNS changes have already been applied.</p>
<h2>Set up Kubernetes</h2>
<p>Kubernetes is a powerful orchestration tool for containers. I use k3s, a lean Kubernetes variant that is particularly suitable for smaller environments.</p>
<h3>Install K3s on the server</h3>
<p>Connect to the server via SSH and install k3s with the following command:</p>
<pre><code class="language-sh">curl -sfL https://get.k3s.io | sh - </code></pre>
<p>The script installs k3s and starts the Kubernetes service. After installation, k3s can be checked with the following command:</p>
<pre><code class="language-sh">kubectl get nodes
</code></pre>
<p>k3s comes with its own kubectl version, so that no separate installation is necessary.</p>
<h3>Create YAML files for FE, BE, MySQL and Redis</h3>
<p>To deploy our application, we need YAML files for:</p>
<ul>
<li>Frontend (Angular)</li>
<li>Backend (NestJS)</li>
<li>Database (MySQL)</li>
<li>Session-Management (Redis)</li>
</ul>
<p>A deployment file for the backend could look like this:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: backend
  template:
    metadata:
      labels:
        app: backend
    spec:
      containers:
        - name: backend
          image: dockerhub-user/backend:latest
          ports:
            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: backend-service
spec:
  selector:
    app: backend
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
  type: ClusterIP
</pre>
<h3>What are deployments and services?</h3>
<ul>
<li>Deployments manage the provision and scaling of containers.</li>
<li>Services ensure a stable network connection between containers.</li>
<li>ClusterIP means that the service is only accessible within the Kubernetes cluster.</li>
</ul>
<h3>Set up Caddy as a reverse proxy</h3>
<p>A reverse proxy is required to ensure that incoming traffic is distributed correctly. K3s comes with Traefik by default, but I opted for a simpler solution: Caddy. I was really surprised how little guidance or documentation there is on Caddy in combination with Kubernetes.</p>
<h3>Why Kubernetes with Caddy?</h3>
<ul>
<li>Automatic Let&#8217;s Encrypt SSL certificates</li>
<li>Simple configuration via Caddyfile</li>
<li>Built-in load balancer</li>
</ul>
<h3>Remove Traefik</h3>
<pre><code class="language-sh">kubectl delete helmrelease traefik -n kube-system
</code></pre>
<h3>Create Caddy Deployment</h3>
<pre class="EnlighterJSRAW" data-enlighter-language="generic">apiVersion: apps/v1
kind: Deployment
metadata:
  name: caddy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: caddy
  template:
    metadata:
      labels:
        app: caddy
    spec:
      containers:
        - name: caddy
          image: caddy
          volumeMounts:
            - name: caddy-config
              mountPath: /etc/caddy/Caddyfile
      volumes:
        - name: caddy-config
          configMap:
            name: caddy-config
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: caddy-config
data:
  Caddyfile: |

    example.com {
        reverse_proxy backend-service:3000
    }

---
apiVersion: v1
kind: Service
metadata:
  name: caddy-service
spec:
  type: LoadBalancer
  selector:
    app: caddy
  ports:
    - port: 80
      targetPort: 80
    - port: 443
      targetPort: 443</pre>
<p>Important: Since Let&#8217;s Encrypt has a rate limit, tests should first be carried out with staging certificates!</p>
<h2>Conclusion</h2>
<p>After these steps, the application is now running in a Kubernetes cluster on a Hetzner VPS and can be accessed via its own domain. The next step would be to set up an automatic CI/CD pipeline to deploy new versions without manual effort.</p>
<p>The post <a href="https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/">Deployment of a WebApp with Kubernetes and Caddy</a> appeared first on <a href="https://nerd-corner.com">Nerd Corner</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nerd-corner.com/deployment-of-a-webapp-with-kubernetes-and-caddy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
