正则表达式替换Traefik提供404

I have a docker that is behind the Traefik proxy. I try to redirect all traffic (except the cdn) to https://www.mysite.nl. I configured a regex as you can see below. But unfortunatly it does not work. I receive 404 on all hosts. What am i missing?

New setup

Here you can test the regex: https://regex101.com/r/mwt573/2

- traefik.frontend.priority=5
- traefik.frontend.rule=Host:mysite.nl, www.mysite.nl, mysite.com, www.mysite.com, cdn.mysite.net
- traefik.frontend.redirect.regex=^https?://(?:www.)?mysite\.(?:nl|com)(.*)
- traefik.frontend.redirect.replacement=https://www.mysite.nl$${1} 

Old setup

This setup worked for me, but did not redirect the .com domain to .nl. It also places a / after each url.

- traefik.frontend.priority=5
- traefik.frontend.rule=Host:mysite.nl, www.mysite.nl, cdn.mysite.net, mysite.com, www.mysite.com
- traefik.frontend.redirect.regex=^https?://mysite.nl/(.*)
- frontend.redirect.replacement=https://www.mysite.nl/$${1}

I am not sure why. But removing the non capturing group and unescaping the dot worked for me.

Working example:

 - traefik.frontend.priority=5
 - traefik.frontend.rule=Host:mysite.nl, www.mysite.nl, cdn.mysite.net, mysite.com, www.mysite.com
 - traefik.frontend.redirect.regex=^https?://(www.)?mysite(.nl|.com)(.*)
 - traefik.frontend.redirect.replacement=https://www.mysite.nl$${3}

I have been suffering with my docker run command (executable script file) and regex/replacement labels for a while. This is what I came to using it for www to non-www url rewrite:

  1. Please note that GO's regex lib is slightly different - GO's regex lib here
  2. You can check with docker inspect command under the "Labels" property, if your regex was caught properly by the run script.
  3. Double and single quotes were an issue, somehow double quotes did not work for me (it might be that the shell strips the double quotes and traefik cannot compute the labels without)... how ever I used single quotes around the expressions without any further issue.
  4. In your examples y'all use periods (dots) which is by definition a wildcard. I tried to escape them, but GO's regex library seems to have missed out to escape the period char, thus I have used the charset [.] (where you do not have to escape periods).
  5. Accessing captured groups in GO's is done by ${}. However I couldn't find it in their regex docs. I have this information from try & error.

My result for www to non-www is:

-l traefik.frontend.redirect.regex='^https?://(?:www[.])(.*)'

-l traefik.frontend.redirect.replacement='https://${1}'

Your claimed solution should work properly, I slightly rewrote it:

-l traefik.frontend.redirect.regex='^https?://(?:www[.])?mysite[.](?:nl|com)(.*)'

-l traefik.frontend.redirect.replacement='https://www.mysite.nl${1}'