<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>nginx &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:nginx</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Tue, 21 Apr 2026 12:42:57 +0000</pubDate>
    <item>
      <title>Secure your API with Client-certificate authenatication in NGINX</title>
      <link>https://blogs.linux.pizza/secure-your-api-with-client-certificate-authenatication-in-nginx</link>
      <description>&lt;![CDATA[After a few hours trying to make it work with my current CA, where the Root is stored offline, AIA, OCSP, CRL and all that stuff is done by the book - I gave up.&#xA;Somehow, the Open Source variant of Nginx does not really like my OCSP setup, no idea why and I have no idea how to troubleshoot that.&#xA;&#xA;Solution? KISS-principle!&#xA;&#xA;I&#39;ll write this down, quick and dirty. But hopefully it helps someone.&#xA;&#xA;Lets start with create the private key for the CA that we will create:&#xA;&#xA;openssl genpkey -algorithm RSA -out CAROOT.key -aes256&#xA;With this command, we have created a private key with AES256. You will be prompted to give a password - write that down.&#xA;And the following command will create a certificate from the private key, valid for 10 years.&#xA;&#xA;openssl req -x509 -new -nodes -key CAROOT.key -sha256 -days 3650 -out CAROOT.crt&#xA;Fill in the information that the above command wants of you, like country-code, and so on.&#xA;After that, your CA is done. The crude, ugly and honestly boring CA. But it&#39;ll work for this usecase.&#xA;&#xA;Let&#39;s create the client-certificate!&#xA;&#xA;First, will start by creating the private.key, and the .csr:&#xA;openssl genpkey -algorithm RSA -out client-cert.key&#xA;openssl req -new -key client.key -out client-cert.csr&#xA;And again, fill out the information wanted by openssl that will populate the .csr. Make it looks pretty.&#xA;Ideally, the commands shall be run on the client only, so the private-key never leaves the client. The .csr is what the CA will need to sign and create a valid certificate.&#xA;&#xA;Bring the .csr to the CA, and sign it:&#xA;&#xA;openssl x509 -req -in client-cert.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client-cert.crt -days 365 -sha256&#xA;This will give you a signed certificate for your client named &#34;client-cert.crt&#34; - you may bring that to the client-machine and install it.&#xA;&#xA;Firefox wants a .pfx:&#xA;&#xA;In order to import the certificate into Firefox, you&#39;ll need to convert it to p12/pfx format:&#xA;openssl pkcs12 -export -out client-cert.pfx -inkey client-cert.key -in client-cert.crt -certfile CAROOT.crt&#xA;Please note, that you&#39;ll need the CAROOT.crt file too that you created.&#xA;&#xA;Configure NGINX to do client-certificate authentication&#xA;&#xA;Navigate to the virtualhost you want to enable client-certificate authentication on, and add the following:&#xA;&#xA;    sslclientcertificate /etc/ssl/private/CAROOT.crt;&#xA;    sslverifyclient on;&#xA;    sslverifydepth 2;&#xA;Please note, that you have to place the CA_ROOT.crt file in &#xA;Restart NGINX and try to visit the site. You&#39;ll probably be asked for permission to use client-certificate authentication.&#xA;&#xA;#linux #openssl #nginx #pki&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p>After a few hours trying to make it work with my current CA, where the Root is stored offline, AIA, OCSP, CRL and all that stuff is done by the book – I gave up.
Somehow, the Open Source variant of Nginx does not really like my OCSP setup, no idea why and I have no idea how to troubleshoot that.</p>

<h4 id="solution-kiss-principle" id="solution-kiss-principle">Solution? KISS-principle!</h4>

<p>I&#39;ll write this down, quick and dirty. But hopefully it helps someone.</p>

<p>Lets start with create the private key for the CA that we will create:</p>

<pre><code>openssl genpkey -algorithm RSA -out CA_ROOT.key -aes256
</code></pre>

<p>With this command, we have created a private key with AES256. You will be prompted to give a password – write that down.
And the following command will create a certificate from the private key, valid for 10 years.</p>

<pre><code>openssl req -x509 -new -nodes -key CA_ROOT.key -sha256 -days 3650 -out CA_ROOT.crt
</code></pre>

<p>Fill in the information that the above command wants of you, like country-code, and so on.
After that, your CA is done. The crude, ugly and honestly boring CA. But it&#39;ll work for this usecase.</p>

<h4 id="let-s-create-the-client-certificate" id="let-s-create-the-client-certificate">Let&#39;s create the client-certificate!</h4>

<p>First, will start by creating the private.key, and the .csr:</p>

<pre><code>openssl genpkey -algorithm RSA -out client-cert.key
openssl req -new -key client.key -out client-cert.csr
</code></pre>

<p>And again, fill out the information wanted by openssl that will populate the .csr. Make it looks pretty.
Ideally, the commands shall be run on the client only, so the private-key never leaves the client. The .csr is what the CA will need to sign and create a valid certificate.</p>

<p>Bring the .csr to the CA, and sign it:</p>

<pre><code>openssl x509 -req -in client-cert.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client-cert.crt -days 365 -sha256
</code></pre>

<p>This will give you a signed certificate for your client named “client-cert.crt” – you may bring that to the client-machine and install it.</p>

<h4 id="firefox-wants-a-pfx" id="firefox-wants-a-pfx">Firefox wants a .pfx:</h4>

<p>In order to import the certificate into Firefox, you&#39;ll need to convert it to p12/pfx format:</p>

<pre><code>openssl pkcs12 -export -out client-cert.pfx -inkey client-cert.key -in client-cert.crt -certfile CA_ROOT.crt
</code></pre>

<p>Please note, that you&#39;ll need the CA_ROOT.crt file too that you created.</p>

<h4 id="configure-nginx-to-do-client-certificate-authentication" id="configure-nginx-to-do-client-certificate-authentication">Configure NGINX to do client-certificate authentication</h4>

<p>Navigate to the virtualhost you want to enable client-certificate authentication on, and add the following:</p>

<pre><code>    ssl_client_certificate /etc/ssl/private/CA_ROOT.crt;
    ssl_verify_client on;
    ssl_verify_depth 2;
</code></pre>

<p>Please note, that you have to place the CA_ROOT.crt file in <code>/etc/ssl/private/</code></p>

<p>Restart NGINX and try to visit the site. You&#39;ll probably be asked for permission to use client-certificate authentication.</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:openssl" class="hashtag"><span>#</span><span class="p-category">openssl</span></a> <a href="https://blogs.linux.pizza/tag:nginx" class="hashtag"><span>#</span><span class="p-category">nginx</span></a> <a href="https://blogs.linux.pizza/tag:pki" class="hashtag"><span>#</span><span class="p-category">pki</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/secure-your-api-with-client-certificate-authenatication-in-nginx</guid>
      <pubDate>Sat, 15 Nov 2025 20:32:09 +0000</pubDate>
    </item>
    <item>
      <title>Kubectl cheat-sheet</title>
      <link>https://blogs.linux.pizza/kubectl-cheat-sheet</link>
      <description>&lt;![CDATA[## Just some random #kubectl commands for myself. I have tested these on 1.20  1.25&#xA;&#xA;Get all ingress logs (if your ingress is nginx)&#xA;kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx&#xA;Get all logs from Deployment&#xA;kubectl logs deployment/deployment -n namespace --watch&#xA;Why is the pod stuck in &#34;ContainerCreating&#34;?&#xA;kubectl get events --sort-by=.metadata.creationTimestamp --watch&#xA;Restart your deployment, nice and clean&#xA;kubectl rollout restart deployment/deployment -n namespace&#xA;Check which namespaces are using the most disk space&#xA;kubectl get namespace --no-headers | xargs -I {} sh -c &#39;echo {}; kubectl get pods -n {} --no-headers | xargs -I {} sh -c &#34;kubectl logs {} -n {} | wc -c&#34;&#39; | awk &#39;{print $1&#34; &#34;($2/1024/1024)&#34; MB&#34;}&#39; | sort -k2 -n -r | head&#xA;Check if any pods are using a lot of disk space&#xA;kubectl get pods --all-namespaces -o json | jq &#39;.items[].spec.containers[].resources.requests.storage&#39; | grep -v null&#xA;Check the Kubernetes event logs for any disk-related errors&#xA;&#xA;kubectl get events --field-selector involvedObject.kind=Node,reason=OutOfDisk&#xA;&#xA;I&#39;ll add more when I find more usefull stuff&#xA;&#xA;#linux #k8s #kubernetes #kubectl #ingress #nginx #deployment #logs]]&gt;</description>
      <content:encoded><![CDATA[<h2 id="just-some-random-kubectl-commands-for-myself-i-have-tested-these-on-1-20-1-25" id="just-some-random-kubectl-commands-for-myself-i-have-tested-these-on-1-20-1-25">Just some random <a href="https://blogs.linux.pizza/tag:kubectl" class="hashtag"><span>#</span><span class="p-category">kubectl</span></a> commands for myself. I have tested these on 1.20 &lt;&gt; 1.25</h2>

<h4 id="get-all-ingress-logs-if-your-ingress-is-nginx" id="get-all-ingress-logs-if-your-ingress-is-nginx">Get all ingress logs (if your ingress is nginx)</h4>

<pre><code>kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx
</code></pre>

<h4 id="get-all-logs-from-deployment" id="get-all-logs-from-deployment">Get all logs from Deployment</h4>

<pre><code>kubectl logs deployment/&lt;deployment&gt; -n &lt;namespace&gt; --watch
</code></pre>

<h4 id="why-is-the-pod-stuck-in-containercreating" id="why-is-the-pod-stuck-in-containercreating">Why is the pod stuck in “ContainerCreating”?</h4>

<pre><code>kubectl get events --sort-by=.metadata.creationTimestamp --watch
</code></pre>

<h4 id="restart-your-deployment-nice-and-clean" id="restart-your-deployment-nice-and-clean">Restart your deployment, nice and clean</h4>

<pre><code>kubectl rollout restart deployment/&lt;deployment&gt; -n &lt;namespace&gt;
</code></pre>

<h4 id="check-which-namespaces-are-using-the-most-disk-space" id="check-which-namespaces-are-using-the-most-disk-space">Check which namespaces are using the most disk space</h4>

<pre><code>kubectl get namespace --no-headers | xargs -I {} sh -c &#39;echo {}; kubectl get pods -n {} --no-headers | xargs -I {} sh -c &#34;kubectl logs {} -n {} | wc -c&#34;&#39; | awk &#39;{print $1&#34; &#34;($2/1024/1024)&#34; MB&#34;}&#39; | sort -k2 -n -r | head
</code></pre>

<h4 id="check-if-any-pods-are-using-a-lot-of-disk-space" id="check-if-any-pods-are-using-a-lot-of-disk-space">Check if any pods are using a lot of disk space</h4>

<pre><code>kubectl get pods --all-namespaces -o json | jq &#39;.items[].spec.containers[].resources.requests.storage&#39; | grep -v null
</code></pre>

<h4 id="check-the-kubernetes-event-logs-for-any-disk-related-errors" id="check-the-kubernetes-event-logs-for-any-disk-related-errors">Check the Kubernetes event logs for any disk-related errors</h4>

<pre><code>kubectl get events --field-selector involvedObject.kind=Node,reason=OutOfDisk
</code></pre>

<p>I&#39;ll add more when I find more usefull stuff</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:k8s" class="hashtag"><span>#</span><span class="p-category">k8s</span></a> <a href="https://blogs.linux.pizza/tag:kubernetes" class="hashtag"><span>#</span><span class="p-category">kubernetes</span></a> <a href="https://blogs.linux.pizza/tag:kubectl" class="hashtag"><span>#</span><span class="p-category">kubectl</span></a> <a href="https://blogs.linux.pizza/tag:ingress" class="hashtag"><span>#</span><span class="p-category">ingress</span></a> <a href="https://blogs.linux.pizza/tag:nginx" class="hashtag"><span>#</span><span class="p-category">nginx</span></a> <a href="https://blogs.linux.pizza/tag:deployment" class="hashtag"><span>#</span><span class="p-category">deployment</span></a> <a href="https://blogs.linux.pizza/tag:logs" class="hashtag"><span>#</span><span class="p-category">logs</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/kubectl-cheat-sheet</guid>
      <pubDate>Tue, 28 Feb 2023 08:04:47 +0000</pubDate>
    </item>
  </channel>
</rss>