Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
This is because your redirect is just a catch all redirecting anything that isn’t already defined. Since your forum.domain.com is configured, the catch all doesn’t do anything; as it’s not needed. You want to update your server block from the forum to listen on 443. Then the default catch-all on port 80 should come into effect here.
I would save your configs and give that a test. As I’ve never done this exact setup, I’m uncertain if it will work. I have done it with docker in the past, just not with Discourse. So it should work, but I’m not 100% certain. If it doesn’t let me know and we can try to work through it.
As for let’s encrypt, yes, you can do that. You would just want to set the ssl_certificate and ssl_certificate_key paths for the forum sub domain.
I think some explanation of how nginx tries to route stuff will help here. You have the 2 catch all server blocks. One for forum and one for your default.
So when you type http://forum.domain.com nginx checks for the forum.domain.com server block (which you have), and routes it based on that block. If I put http://example.domain.com nginx is going to look for that, which you don’t have. So it defaults to the catch-all, which is the redirect. So it will redirect me to https://example.domain.com and check for that. Which you don’t have. But you have a catch all for that with the *.domain.com server_name value. So it routes me to that.
If you modify things so that you have the forum.domain.com server block listening on 443, it won’t get caught by the 443 catch all and will route to https properly. You just have to define the ssl_certificate and ssl_certificate_key paths in that block.
Then, since you removed the listen 80 for forum.domain.com it will get caught by the catch all and be routed to https.
At least it should, if my quick testing of nginx routes was correct.