title: k8s ngnix container return json response
body: <p>I have a k8s cluster, among other things running an nginx.
  when I do <code>curl -v &lt;url&gt;</code> I get </p>
  
  <pre><code>    HTTP/1.1 200 OK
  &lt; Content-Type: text/html
  &lt; Date: Fri, 24 Mar 2017 15:25:27 GMT
  &lt; Server: nginx
  &lt; Strict-Transport-Security: max-age=15724800; includeSubDomains; preload
  &lt; Content-Length: 0
  &lt; Connection: keep-alive
  &lt;
  * Curl_http_done: called premature == 0
  * Connection #0 to host &lt;url&gt; left intact
  </code></pre>
  
  <p>however when I do <code>curl -v &lt;url&gt; -H 'Accept: application/json'</code> I get</p>
  
  <pre><code>&lt; HTTP/1.1 200 OK
  &lt; Content-Type: text/html
  &lt; Date: Fri, 24 Mar 2017 15:26:10 GMT
  &lt; Server: nginx
  &lt; Strict-Transport-Security: max-age=15724800; includeSubDomains; preload
  &lt; Content-Length: 0
  &lt; Connection: keep-alive
  &lt;
  * Curl_http_done: called premature == 0
  * Connection #0 to host &lt;url&gt; left intact
  * Could not resolve host: application
  * Closing connection 1
  curl: (6) Could not resolve host: application
  </code></pre>
  
  <p>My task is to get the request to return a json not html.
  To my understanding I have to create an ingress-controller and modify the ngnix.conf somehow, I've been trying for a few days now but can't get it right. Any kind of help would be most appreciated.</p>
  
  <p>The following are of the yaml files I've been using:</p>
  
  <p>configmap:</p>
  
  <pre><code>apiVersion: v1
  data:
    server-tokens: "false"
    proxy-body-size: "4110m"
    server-name-hash-bucket-size: "128"
  kind: ConfigMap
  metadata:
    name: nginx-load-balancer-conf
    labels:
      app: nginx-ingress-lb
  </code></pre>
  
  <p>daemonset:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: DaemonSet
  metadata:
    name: nginx-ingress-lb
    labels:
      app: nginx-ingress-lb
  spec:
    template:
      metadata:
        labels:
          name: nginx-ingress-lb
          app: nginx-ingress-lb
  
      spec:
        terminationGracePeriodSeconds: 60
        nodeSelector:
          NodeType: worker
        containers:
        - image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.1
  
          name: nginx-ingress-lb
          imagePullPolicy: Always
          readinessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            timeoutSeconds: 1
          # use downward API
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
          - containerPort: 80
            hostPort: 80
          - containerPort: 443
            hostPort: 443
          args:
          - /nginx-ingress-controller
          - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
          - --configmap=$(POD_NAMESPACE)/nginx-load-balancer-conf
  </code></pre>
  
  <p>deployment:</p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Deployment
  
  metadata:
    name: default-http-backend
    labels:
      app: default-http-backend
  
  spec:
    replicas: 2
    template:
  
      metadata:
        labels:
          app: default-http-backend
  
      spec:
        terminationGracePeriodSeconds: 60
        containers:
        - name: default-http-backend
          # Any image is permissable as long as:
          # 1. It serves a 404 page at /
          # 2. It serves 200 on a /healthz endpoint
          image: gcr.io/google_containers/defaultbackend:1.2
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 30
            timeoutSeconds: 5
          ports:
          - containerPort: 8080
          resources:
            limits:
              cpu: 100m
              memory: 20Mi
            requests:
              cpu: 100m
              memory: 20Mi
  </code></pre>
  
  <p>service:</p>
  
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: default-http-backend
    labels:
      app: default-http-backend
  spec:
    selector:
      app: default-http-backend
    ports:
    - port: 80
      targetPort: 8080
  </code></pre>