Hoe maak je een 301 redirect naar een nieuw domein

Thank you, I have a few questions.

I have the following lines in the config file:

server {
   listen 80
    return 301 https://domain1.com$request_uri
}

I don’t know why 301 it’s there by default. Should I override that or create a new one above or below it (what you provided). Is server_name necessary?

Will that break the LetsEncrypt renewal process if I redirect everything?