So I’ve a domain example[.]com hosted on my MIAB server. I’ve a mail server for the same.
Now I am hosting another application on port 8000
on the same server and have added in the nginx conf the following -
server {
listen 80;
server_name myapp[.]example[.]com;
# redirect all HTTP to HTTPS
return 301 https[://]$host$request_uri;
}
server {
listen 443 ssl;
server_name myapp[.]example[.]com;
ssl_certificate /etc/letsencrypt/live/myapp[.]example[.]com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/myapp[.]example[.]com/privkey.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
# HSTS (ngx_http_headers_module is required) (63072000 seconds)
# Uncomment if desired
#add_header Strict-Transport-Security "max-age=63072000" always;
ssl_stapling on;
ssl_stapling_verify on;
client_max_body_size 0;
proxy_read_timeout 300;
location / {
include proxy_params;
proxy_pass http[://]127.0.0.1:8000;
}
}
Now I’ve got the cert for the myapp
subdomain using certbot
on the same machine.
I’ve also added a DNS entry with myapp[.]example[.]com
in the Custom DNS section of MIAB.
But whenever I open myapp[.]example[.]com
it shows certificate invalid and when I check the certificate it shows the certifcate for box[.]example[.]com
, hence the error. Like this -
P.S. I’ve to add []
to links as new users can’t post links.