The discussion focuses on setting up a 301 redirect from domain1.com to domain2.com using Nginx. Idan initially asks about modifying the nginx.conf file, specifically whether changing the if condition and rewrite rule will work. itsbhanusharma provides a recommended configuration using a server block with return 301, emphasizing that this should be done in the app.yml file if inside the Discourse container, not directly in nginx.conf. Idan confirms he is inside the container and seeks clarification on whether the existing 301 redirect will interfere with Let’s Encrypt renewal. itsbhanusharma directs him to a relevant meta post and highlights the need to exclude the .well-known/acme-challenge path from the redirect to avoid renewal issues, referencing a known problem with 301 redirects and Let’s Encrypt.
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?
Are you editing nginx.conf inside the discourse container or an external nginx reverse proxy?
If it is internal, you should instead be doing it in the app.yml file. There are multiple examples on how to do that
If you are doing it on an external nginx rp then you can create a new file say redirect.conf in the /etc/nginx/conf.d folder with the configuration example I provided.
@itsbhanusharma I am implementing the code right now. My question is whether LetsEncrypt will renew itself as I intend to live the old server for some time until the URLs are changed by Google. Is there anything I need to add so LetsEncrypt renewal won’t fail due to this 301 redirection change?