Using different port for http proxy causes redirects to fail
Hello, I'm using Docker compose, the latest NextCloud fpm docker image, mariadb, nginx to access the fpm-port on the NextCloud image, nginx-proxy to proxy SSL requests from my external domain to my internal Docker app, and acme-companion for automatic SSL cert renewals. I followed examples in https://github.com/nextcloud/docker/tree/master/.examples/docker-compose/with-nginx-proxy/mariadb/fpm.
Since my Docker host is already using ports 443 and 80, if I use the example docker-compose.yml as is it causes a port conflict, since the proxy configured in the example exposes ports using 80:80 and 443:443. Instead, I use 6080 for HTTP and 6443 for HTTPS by setting HTTP_PORT and HTTPS_PORT environment variables respectively, described at https://github.com/nginx-proxy/nginx-proxy/blob/main/README.md . In my docker-compose file, I set 6080:6080 and 6443:6443 on my proxy to expose the ports. On my public facing router, I port forward 443 to my docker host on port 6443 and 80 to my docker host on 6080.
The LetsEncrypt ACME companion is working fine and my HTTPS connection to the NextCloud app seems to be working fine externally.
I can access my setup initially to run through the setup wizard, but it eventually redirects to https://mydomain.tld:6443/login which is not what I was expecting (I was expecting it to route to https://mydomain.tld/login) . I got around this initially by setting the OVERWRITEHOST to mydomain.tld:443, OVERWRITEPROTOCOL to https, and OVERWRITECLIURL to https://mydomain.tld. This allowed me to proceed with the login.
However, when I visit Settings -> Administration -> Overview, I get warnings saying, Your web server is not properly set up to resolve "/.well-known/webfinger". I tried visiting https://mydomain.tld/.well-known/webfinger, but it forwards me to https://mydomain.tld:6443/index.php/.well-known/webfinger . Presumably, this is because in the sample nginx.conf provided here: https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf, on line 119 it says: return 301 /index.php$request_uri;. This makes me think that setting the overwrite variables mentioned above is really a bandaid that is masking a bigger problem.
It seems like my nginx-proxy reverse proxy is adding port 6443 to any response which redirects. I'm not terribly familiar with nginx or nginx-proxy configuration. Any suggestions on how to configure this properly by allowing my proxy to exist on different ports other than 80/443?