Nginx Reverse Proxy Adds a Container Port

We have a Kubernetes cluster where we expose an internal service with Nginx. Note that we do not use an ingress resource, but instead deploy a Nginx controller bound to an external IP address. As a result, the Nginx container listens on ports 8080 and 8443 (the link to 80 and 443 is not possible because this would require root access) and requests to port 80 and 443 are passed to the container.

The service on display works on https: // and is accessible without problem.

However, when connecting to the service with the help of SAML 2.0, the callback is redirected to https: //8443 instead of the expected https: //. The callback URL is https: /// oauth2 / saml / callback

Here is our nginx configuration. Does anyone have any idea of ​​why this could happen?

server {
listen to 8080;
return 301 https: // $ host $ request_uri;
}
server {
servername service-url;
listen to 8443;
ssl on;
ssl_certificate ...;
ssl_certificate_key ...;
ssl_session_timeout 5m;

location / {
client_max_body_size 100m;
proxy_set_header X-Forwarded-Host $ host;
proxy_set_header X-Forwarded-Server $ host;
proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http: //;
}
}

As you can see, for some reason, Nginx thinks that the request needs to be redirected and adds its own container port. Any ideas on why this could happen and how to fix it?