Lets Encrypt across two ports

Hi,

Apologies in advance: I am new to servers and certificates.

I have two nodejs apps running on one server instance. The first is the client facing app (http://localhost:3000), and this makes calls to the second app (webservices http://localhost:3001).

This is my nginx sites available:

server {

        root /var/www/mydomain.com/html;
        index index.html index.htm index.nginx-debian.html;

        server_name mydomain.com www.mydomain.com;

        location / {
                proxy_pass http://localhost:3000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
        }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed >
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; # manage>
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.mydomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

Thanks to the LetsEncrypt certificate, the site is available at https://mydomain.com. This calls http://localhost:3001 to reach the webservices. The services are reached, but I need them to be HTTPS also.

Is this possible with one LetsEncrypt certificate? I’m trying to avoid spinning up another droplet and domain for my webservices.

1 Like