Kubernetes-ingress: [Question] is it possible to set proxy_http_version to 1.1 for 1 particular ingress?

Created on 7 Jun 2018  路  6Comments  路  Source: nginxinc/kubernetes-ingress

Is it possible to set proxy_http_version to 1.1 for 1 particular ingress?

question

Most helpful comment

A more general question: Is it possible to have different configurations for different paths in the ingress which is evaluated to something like this in the nginx config?

Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:

  • host: "example.io"
    http:
    paths:

    • path: /status/

      backend:

      serviceName: example-app

      servicePort: 8080

    • path: /stats

      backend:

      serviceName: example

      servicePort: 8080

nginx.conf
``

location /status/example-app {
  proxy_pass https://example-app/status;
  proxy_http_version 1.1;
}

location /stats {
  include /public/cors_support;
  proxy_pass http://example/stats;
  proxy_http_version 1.1;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP       $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Connection      '';
  chunked_transfer_encoding off;
  proxy_buffering off;
  proxy_cache off;
}

All 6 comments

A more general question: Is it possible to have different configurations for different paths in the ingress which is evaluated to something like this in the nginx config?

Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example
namespace: default
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:

  • host: "example.io"
    http:
    paths:

    • path: /status/

      backend:

      serviceName: example-app

      servicePort: 8080

    • path: /stats

      backend:

      serviceName: example

      servicePort: 8080

nginx.conf
``

location /status/example-app {
  proxy_pass https://example-app/status;
  proxy_http_version 1.1;
}

location /stats {
  include /public/cors_support;
  proxy_pass http://example/stats;
  proxy_http_version 1.1;
  proxy_set_header Host $http_host;
  proxy_set_header X-Real-IP       $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Connection      '';
  chunked_transfer_encoding off;
  proxy_buffering off;
  proxy_cache off;
}

it seems that's harder because the annotations location in the yaml seems to be shared for all paths.

okay thanks for the quick answer.

@tuananh @stmaute
it is possible to apply certain annotations per path with Mergeable Ingress resources -- https://github.com/nginxinc/kubernetes-ingress/tree/master/examples/mergeable-ingress-types This way you can split an Ingress resource with multiple paths into multiple Ingress resources, each with one or more paths, and apply annotation per Ingress resource.

@pleshakov this is awesome. lemme take a look at that. Thanks.

@pleshakov that is exactly what I looked for thank you. I must have overseen this when I looked around the repo.

Was this page helpful?
0 / 5 - 0 ratings