Mailu working, but redirecting to it with linuxserver/letsencrypt's Nginx?

Until I was editing this post I had a problem where if I went to the main mail domain ie. “mail.domain.tld/” I would receive a 500. While putting this post together, I noticed in the mailu.env file…


After changing that to /webmail problem fixed, but what if I didn’t use that variable and wanted to go “front/webmail” directly? I tried to return 301’s, rewrites, setting various x-headers and I always received a bad gateway or mostly bad redirects. I tried the method from mailu’s help of using, but at that point I didn’t understand how to write the mailu.subdomain.conf in a way that it uses 4444 which is where I started using x-headers.