Ingress Controller Allow dynamic port in Access-Control-Allow-Origin

I need to specify random port for

My configuration is:

  annotations: "true" "GET, POST, PUT, DELETE, OPTIONS" "true" 3600 "Cache-Control,Content-Type,Authorization,Origin,Accept" |
      if ($http_origin ~* (^(http://localhost(:\d+)?)$|^(https://(.+\.)?$)) {
      more_set_headers "Access-Control-Allow-Origin: $http_origin";

But Access-Control-Allow-Origin value overrided for requests and it shows ‘*’

btw: by default eq ‘*’ ( ingress-nginx/ at main · kubernetes/ingress-nginx · GitHub)

Can I set allowed origin using Access-Control-Allow-Origin ?

Cluster information:

Kubernetes version: 1.24
Installation method: Helm
Image: GitHub - kubernetes/ingress-nginx: Ingress-NGINX Controller for Kubernetes
Version: v1.5.1