<p>I'm using Azure Kubernetes to a host Angular web app using Docker Container.
I have created SSL certificate using OpenSSL commands. Now, I need to configure HTTPS and SSL certificate to my web app.</p>
<p>Please help me how to set up these?</p>
<p>Here's my <strong>Docker</strong> File</p>
<pre><code>FROM nginx:latest as nginx
RUN rm -rf /usr/share/nginx/html/*
COPY /dist/merch-insight/nginx.conf /etc/nginx/conf.d/nginx.conf
COPY /dist/merch-insight /usr/share/nginx/html
EXPOSE 80
CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]
</code></pre>
<p>Here's my <strong>nginx.conf</strong> file</p>
<pre><code>server {
  server_name my-app;
  charset utf-8;
  sendfile on;
  root /usr/share/nginx/html;

  #Caches static assets
  location ~ ^/(assets|bower_components|scripts|styles|views) {
    expires     31d;
    add_header  Cache-Control public;
  }

  #Caches Bundles created by angular cli
  location ~* \.(?:bundle.js|bundle.css)$ {
    expires 1M;
    access_log off;
    add_header Cache-Control &quot;public&quot;;
  }

  ##
  # Main file index.html sending not found locations to the main
  ##
  location / {
    expires -1;
    add_header Pragma &quot;no-cache&quot;;
    add_header Cache-Control &quot;no-store, no-cache, must-revalidate, post-check=0, pre-check=0&quot;;
    index index.html index.htm;
    try_files $uri $uri/ /index.html;
  }
}
</code></pre>
<p>And here is my <strong>yaml</strong> file</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: apweb
    version: v1
  name: apweb
  namespace: default
spec:
  selector:
    matchLabels:
      run: apweb
  replicas: 2

  template:
    metadata:
      labels:
        run: apweb
    spec:
      containers:
      - name: apweb
        image: mycontainerregistry.azurecr.io/apweb:dev
        imagePullPolicy: Always
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: apweb
    version: v1
  name: apweb-service
  namespace: default
spec:
  type: LoadBalancer
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
    name: http-web
  selector:
    run: apweb
</code></pre>

<p>In k8s you can use nginx ingress controller (or other ingress options) to configure <a href="https://en.wikipedia.org/wiki/TLS_termination_proxy" rel="nofollow noreferrer">TLS termination</a>.</p>
<p>Please take a look at this example from nginx ingress <a href="https://kubernetes.github.io/ingress-nginx/examples/tls-termination/" rel="nofollow noreferrer">documentation</a>.</p>
<p><a href="https://kubernetes.github.io/ingress-nginx/examples/PREREQUISITES/#tls-certificates" rel="nofollow noreferrer">Here</a> it is explained how to generate k8s secret for you TLS certificate.</p>
<p><a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">Here</a> you can find the full installation guide.</p>
