Www.example.com OK, but example.com NOT

It’s likely more than that. You also need to deal with Let’s Encrypt and your proxy to make this work if you are using https (like you should!)

See:

If I were you, keep it simple and use only one.