nginx cname redirect to other site setup
I have a website which uses an affiliate program. Also, I am using ssl certificate and nginx using let us encrypt. I need to redirect the subdomain "service.mydomain.com" to affiliate.com. The Affiliate provider supports URL masking, and based on their tutorial I need to add a CNAME record (name,value ) as (service, cname.affilate.com). Wen I have added this record I got an ssl certificate error because "service" subdomain does not have an ssl certificate. So I have removed the CNAME record and added an A record to expand ssl certificate. Then I tried to add cname record again, but CNAME record can not have the same name as an A record. my question is how o configure this using nginx, letus encrypt and CANME?. I am lost and I am not able to track how this should work.