I have removed all files from /etc/nginx/sites-enabled/ directory.
I have also removed all files from /etc/nginx/sites-available/ directory.
I only have one file in /etc/nginx/conf.d/ called my-domain-name.com.conf and it contains:
server {
listen 80;
server_name my-domain-name.com www.my-domain-name.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name my-domain-name.com www.my-domain-name.com;
ssl_certificate /etc/letsencrypt/live/my-domain-name.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-domain-name.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
location / {
proxy_pass http://localhost:4000;
}
}
I proxy traffic to a docker container that listens on port 4000.
It works great for my-domain-name.com and www.my-domain-name.com.
However, it also redirects ALL of my subdomains that have been defined in DNS.
This is not the intended behavior. I only want this file to serve these two domains, not more.
What is wrong here?
Update:
I added another file, called sudomain.my-domain-name.com.conf and I added this configuration inside it:
server {
listen 80;
server_name subdomain.my-domain-name.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name subdomain.my-domain-name.com;
ssl_certificate /etc/letsencrypt/live/my-domain-name.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-domain-name.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
location / {
proxy_pass http://localhost:3131;
}
}
And nginx -t shows success and nginx -s reload is also applied. But again when I go to subdomain.my-domain-name.com, instead of getting my second docker that is running on port 3131, again I'm redirected to my-domain-name.com page.