Kubernetes nginx-ingress ingress controller CORS handled by application

Gerard Wilkinson

I am struggling to get NGINX to proxy the CORS headers back and forth from my application. The allowed origins are specified by my ASP.NET Web Application and I would like to proxy these headers back to the client. The application runnning outside of Kubernetes handles CORS headers perfectly so it appears that the application has CORS configured correctly. The Kubernetes NGINX ingress controller doesn't seem to allow me to do this as far as I can tell.

I would like to continue to allow my applicaiton to handle the allowed origins and therefore I just need to configure the NGINX reverse proxy to pass all headers. Looking at the documentation proxy_pass_request_headers is set to on by default. My previous understanding of NGINX is that this config setting is what is required when proxying to another server in order for headers to be passed backwards and forwards.

The annotations enable-cors and the various configration options around CORS outlined in the documentation are of little use to me as they assume that the Ingress Controller is the source of truth on the allowed origins. Which in my case it is not.

I would have expected this to be a common request to allow the application to handle CORS but I am struggling to find any soltions to this issue.

Many thanks in advance for any help anyone can provide!

UPDATE - Add Diagram

I have created a little diagram with my understanding of the topology here. This may well be an oversimplification of the process but hopefully you can understand what I am trying to achieve more easily. enter image description here

Gerard Wilkinson

So this was actually related to a few other issues I was having. CORS headers were not being stripped after all. I had suspicions that the CORS module wasnt configured in a typical IIS container after doing a significant amount of debugging. This was the first issue. https://github.com/microsoft/dotnet-framework-docker/issues/625

For those that are interested here is the DockerFile lines for adding in CORS with Chocolatey:

RUN Set-ExecutionPolicy Bypass -Scope Process -Force; `
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; `
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')); `
    choco install iis-cors-module -y

The Kubernetes NGINX wasnt stripping headers and was indeed proxying all headers as normal.

A few other interesting tidbits if anyone else experiences similar issues in future:

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Ingress controller nginx kubernetes not working

分類Dev

Kubernetes ingress controller

分類Dev

Kubernetes internal nginx ingress controller with SSL termination & ssl-passthrough

分類Dev

Kubernetes NGINX Ingress TLS issue

分類Dev

Scale Azure nginx ingress controller

分類Dev

Google Cloud Kubernetes Nginx Ingress hang on "Creating ingress"

分類Dev

Disable SSL redirect for Kubernetes NGINX ingress

分類Dev

Kubernetes ingress controller expose to specific port

分類Dev

Accessing nginx ingress controller on port 80

分類Dev

Automatically Create ClusterRoleBinding on GKE for NGINX Ingress Controller

分類Dev

エラー:getaddrinfo ENOTFOUND ingress-nginx.ingress-nginx-controller.svc.cluster.local

分類Dev

Nginx Ingress ControllerはKubernetesでどのように機能しますか?

分類Dev

Create kubernetes nginx ingress without GCP load-balancer

分類Dev

Kubernetes NGINX Ingress with Angular return wrong MIME-Type

分類Dev

Kubernetes Ingress - Rewrite path

分類Dev

Kubernetes ingress conditional routing

分類Dev

Nginx Ingress:サービス「ingress-nginx-controller-admission」が見つかりません

分類Dev

Nginx Ingress:サービス「ingress-nginx-controller-admission」が見つかりません

分類Dev

Ingress-Nginx-Routing in Kubernetes (Konvertierung von Docker-Compose mit Nginx-Reverse-Proxy)

分類Dev

ingress-controllerとGooglekubernetes

分類Dev

Kubernetes ingress-nginx sticky session isn't working with spring security

分類Dev

Kubernetes NGINX Ingress configmap301リダイレクト

分類Dev

Nginx.ingress.kubernetes.io/proxy-body-sizeが機能しない

分類Dev

Kubernetes ingress-nginxで502エラーが発生する(Bad Gateway)

分類Dev

kubernetes nginx ingress //ヘルスチェックが機能しない

分類Dev

Kubernetes Nginx Ingressイメージのバグ/エラー?

分類Dev

AWS EKS上のnginx-ingress-controllerの複数のレプリカ

分類Dev

Nginx Ingress Controller:ホスト変数の目的は何ですか?

分類Dev

Kubernetes Ingressの502 Bad Gateway

Related 関連記事

  1. 1

    Ingress controller nginx kubernetes not working

  2. 2

    Kubernetes ingress controller

  3. 3

    Kubernetes internal nginx ingress controller with SSL termination & ssl-passthrough

  4. 4

    Kubernetes NGINX Ingress TLS issue

  5. 5

    Scale Azure nginx ingress controller

  6. 6

    Google Cloud Kubernetes Nginx Ingress hang on "Creating ingress"

  7. 7

    Disable SSL redirect for Kubernetes NGINX ingress

  8. 8

    Kubernetes ingress controller expose to specific port

  9. 9

    Accessing nginx ingress controller on port 80

  10. 10

    Automatically Create ClusterRoleBinding on GKE for NGINX Ingress Controller

  11. 11

    エラー:getaddrinfo ENOTFOUND ingress-nginx.ingress-nginx-controller.svc.cluster.local

  12. 12

    Nginx Ingress ControllerはKubernetesでどのように機能しますか?

  13. 13

    Create kubernetes nginx ingress without GCP load-balancer

  14. 14

    Kubernetes NGINX Ingress with Angular return wrong MIME-Type

  15. 15

    Kubernetes Ingress - Rewrite path

  16. 16

    Kubernetes ingress conditional routing

  17. 17

    Nginx Ingress:サービス「ingress-nginx-controller-admission」が見つかりません

  18. 18

    Nginx Ingress:サービス「ingress-nginx-controller-admission」が見つかりません

  19. 19

    Ingress-Nginx-Routing in Kubernetes (Konvertierung von Docker-Compose mit Nginx-Reverse-Proxy)

  20. 20

    ingress-controllerとGooglekubernetes

  21. 21

    Kubernetes ingress-nginx sticky session isn't working with spring security

  22. 22

    Kubernetes NGINX Ingress configmap301リダイレクト

  23. 23

    Nginx.ingress.kubernetes.io/proxy-body-sizeが機能しない

  24. 24

    Kubernetes ingress-nginxで502エラーが発生する(Bad Gateway)

  25. 25

    kubernetes nginx ingress //ヘルスチェックが機能しない

  26. 26

    Kubernetes Nginx Ingressイメージのバグ/エラー?

  27. 27

    AWS EKS上のnginx-ingress-controllerの複数のレプリカ

  28. 28

    Nginx Ingress Controller:ホスト変数の目的は何ですか?

  29. 29

    Kubernetes Ingressの502 Bad Gateway

ホットタグ

アーカイブ