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.