<p>I am trying to set up Kubernetes with bare machine and I have deployed my Nginx in the default namespace and I am trying to create a virtual server to route the dashboard. However, when I try to access the URL, it directed me to error 404 and when I view the logs from the pod it seems to be having a broken header. I came across <a href="https://github.com/kubernetes/ingress-nginx/issues/3996" rel="nofollow noreferrer">kubernetes/ingress-nginx#3996</a> and they were giving suggestions to add the proxy protocol and if I were to add the below snippet to my config map, the other routes will fail.</p>
<pre><code>proxy-protocol: &quot;True&quot;
real-ip-header: &quot;proxy_protocol&quot;
set-real-ip-from: &quot;0.0.0.0/0&quot;
</code></pre>
<p>logs:</p>
<pre><code>2021/04/27 07:43:28 [error] 145#145: *155 broken header: &quot;▬♥☺☻☺☺�♥♥�#�↓�|��-�B�d�s�HZ��]!��↨��☻ O|����%���o�/k��R       ��¶�u�♂����VI&quot;��‼☺‼☻‼♥�+�/�,�0̨̩�‼�¶��/&quot; while reading PROXY protocol, client: 192.168.254.9, server: 0.0.0.0:443  
</code></pre>
<p>nginx-config-map.yaml</p>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-ingress-cm
  namespace: default
data:
  http2: &quot;true&quot;
  ssl-protocols: TLSv1.2 TLSv1.3
  ssl-prefer-server-ciphers: &quot;true&quot;
  ssl-ciphers: ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM- 
  SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
  set-real-ip-from: 0.0.0.0/0
  real-ip-header: X-Forwarded-For
  server-snippets: |
    proxy_hide_header Strict-Transport-Security;
    add_header Strict-Transport-Security &quot;max-age=31536000&quot; always;
</code></pre>
<p>Any hints what I have done wrongly? Thanks in advance.</p>
<p>adding the service yaml, as for the dashboard i am using the recommended setup from the source (<a href="https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml" rel="nofollow noreferrer">dashboard.yaml</a>).
nginx-ingress-service</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress-svc
  namespace: default
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: HTTP
  - port: 443
    targetPort: 443
    protocol: TCP
    name: https
  selector:
    app: nginx-ingress
</code></pre>
<p>Virtual server for dashboard.yaml</p>
<pre><code>apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
  name: kubernetes-dashboard-vs
  namespace: kubernetes-dashboard
spec:
  host: k8.moonshot.com
  tls:
    secret: nginx-tls-secret
    redirect:
      enable: true
      code: 301
  upstreams:
  - name: kubernetes-dashboard
    service: kubernetes-dashboard
    port: 443
  routes:
  - path: /
    action:
      pass: kubernetes-dashboard
</code></pre>

rosepalette
<p>I have posted the <a href="https://github.com/nginxinc/kubernetes-ingress/issues/1558" rel="nofollow noreferrer">issue on the github repository</a> and managed to fix it.</p>
<p>Solution suggested by community member is:</p>
<blockquote>
<p>the 400 response code is because NGINX sent an HTTP request to the HTTPs port on the dashboard. To fix that, it is necessary to enable HTTPs between NGINX and the dashboard.</p>
</blockquote>
<p>Virtualserver yaml has to be updated with following:</p>
<pre><code>  - name: kubernetes-dashboard
    service: kubernetes-dashboard
    port: 443
    tls:
      enable: true
</code></pre>
<p>This example applicable for <strong>bare machine kubernetes</strong></p>
