Traefik HTTPS use hostname instead to IP

I have a NiFi instance running on Docker, we use a Reverse-Proxy**(Traefik)** to send the requests to the NiFi docker instance.
When my NiFi instance is running on HTTP I am able to reach the NiFi UI from the internet. Considering we wanted to have login option, I was working to setup HTTPS as login auth is not possible on HTTP NiFi instance.The setup is all working when I apply a global level SSL verify skip in the Reverse-Proxy level using insecureSkipVerify, but I would not want to do that and when I am on the normal setup to verify the certificates that are generated by NiFi automatically which is a Self-Signed cert it fails with the following error

{"level":"debug","msg":"'500 Internal Server Error' caused by: x509: cannot validate certificate for 10.0.2.60 because it doesn't contain any IP SANs","time":"2022-10-21T10:29:18Z"}

Also checked the /etc/hosts file

root@mynifi:/opt/nifi/nifi-current/conf# cat /etc/hosts
127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.2.60       mynifi

The issue is when Traefik is acting as the load-balancer it seems to be trying to access the service using IP address instead of Hostname

{"ForwardURL":{"Scheme":"https","Opaque":"","User":null,"Host":"10.0.2.60:8443","Path":"","RawPath":"","OmitHost":false,"ForceQuery":false,"RawQuery":"","Fragment":"","RawFragment":""},"Request":"{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/nifi/\",\"RawPath\":\"\",\"OmitHost\":false,\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\",\"RawFragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.5\"],\"Cache-Control\":[\"max-age=0\"],\"Cookie\":[\"__Secure-Request-Token=00c9e232-fb30-44e0-a41e-fc0b5ba6b9b5\"],\"Te\":[\"trailers\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0\"],\"X-Forwarded-Host\":[\"example.domain.com\"],\"X-Forwarded-Port\":[\"443\"],\"X-Forwarded-Proto\":[\"https\"],\"X-Forwarded-Server\":[\"d9c0b0e2855e\"],\"X-Proxyhost\":[\"example.domain.com\"],\"X-Proxyport\":[\"443\"],\"X-Proxyscheme\":[\"https\"],\"X-Real-Ip\":[\"143.155.67.98\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"example.domain.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"192.168.52.48:51731\",\"RequestURI\":\"/nifi/\",\"TLS\":null}","level":"debug","msg":"vulcand/oxy/roundrobin/rr: Forwarding this request to URL","time":"2022-10-21T15:23:35Z"}

Is there an option to have the hostname defined within the docker-compose file to be used instead of the IP as my service is accessible using the hostname as I was able to confirm that via the curl command on the docker container.

As the docker containers IP keeps changing each time its redeployed I would really be difficult to generate a certificate with IP of the container.

I tried to use the below labels but I am not sure if its the right one to use in this case

- "traefik.http.middlewares.nifi-redirect.redirectregex.permanent=true"
- "traefik.http.middlewares.nifi-redirect.redirectregex.regex=^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):8443"
- "traefik.http.middlewares.nifi-redirect.redirectregex.replacement=mynifi:8443"

Please do let me know if any additional details are needed

There seems to be two options for insecureskipverify:

One option to set it in the global static config (docker-compose command, not with labels). See docs.

Or you create a dynamic serverTransport and then assign it to a service, all in labels of your service. See docs.

- "traefik.http.services.nifi-flow.loadbalancer.serverstransport.insecureskipverify=true"
- "traefik.http.services.nifi-flow.loadbalancer.serverstransports.insecureskipverify=true"

I tried both the above labels, but it doesn't seem to take effect.

Also, I wanted to know if I can someway instruct Traefik to make the request using the hostname defined instead of the IP

For example

Traefik calls my service using the IP of the container i.e https://10.0.2.90:8443/nifi

I would prefer to use the hostname and Traefik reaches the container using https://mynifi:8443/nifi

My understanding is the default provider.docker behavior is to use the IP. That way Traefik can do the load balancing between multiple containers of the same service.

Be aware that Traefik is currently connecting to you service with the IP, but it should still have the hostname (and path) in the forwarded HTTP request.

If you want to set it to a fixed hostname (which would be load balanced by docker (swarm) if you have multiple containers), you can set up the router with a service with loadBalancer with your hostname.

{
  "ForwardURL": {
    "Scheme": "https",
    "Opaque": "",
    "User": null,
    "Host": "10.0.2.60:8443",
    "Path": "",
    "RawPath": "",
    "OmitHost": false,
    "ForceQuery": false,
    "RawQuery": "",
    "Fragment": "",
    "RawFragment": ""
  },
  "Request": "{\"Method\":\"GET\",\"URL\":{\"Scheme\":\"\",\"Opaque\":\"\",\"User\":null,\"Host\":\"\",\"Path\":\"/nifi/\",\"RawPath\":\"\",\"OmitHost\":false,\"ForceQuery\":false,\"RawQuery\":\"\",\"Fragment\":\"\",\"RawFragment\":\"\"},\"Proto\":\"HTTP/2.0\",\"ProtoMajor\":2,\"ProtoMinor\":0,\"Header\":{\"Accept\":[\"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\"],\"Accept-Encoding\":[\"gzip, deflate, br\"],\"Accept-Language\":[\"en-US,en;q=0.5\"],\"Cache-Control\":[\"max-age=0\"],\"Cookie\":[\"__Secure-Request-Token=00c9e232-fb30-44e0-a41e-fc0b5ba6b9b5\"],\"Te\":[\"trailers\"],\"Upgrade-Insecure-Requests\":[\"1\"],\"User-Agent\":[\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0\"],\"X-Forwarded-Host\":[\"example.domain.com\"],\"X-Forwarded-Port\":[\"443\"],\"X-Forwarded-Proto\":[\"https\"],\"X-Forwarded-Server\":[\"d9c0b0e2855e\"],\"X-Proxyhost\":[\"example.domain.com\"],\"X-Proxyport\":[\"443\"],\"X-Proxyscheme\":[\"https\"],\"X-Real-Ip\":[\"143.155.67.98\"]},\"ContentLength\":0,\"TransferEncoding\":null,\"Host\":\"example.domain.com\",\"Form\":null,\"PostForm\":null,\"MultipartForm\":null,\"Trailer\":null,\"RemoteAddr\":\"192.168.52.48:51731\",\"RequestURI\":\"/nifi/\",\"TLS\":null}",
  "level": "debug",
  "msg": "vulcand/oxy/roundrobin/rr: Forwarding this request to URL",
  "time": "2022-10-21T15:23:35Z"
}

I see the Host is blank in the above request, is there an option to explicitly instruct Traefik to use the Hostname to make the request.

Also I am fine to use the Hostname as the use case is to have just one container for the service.