sudo certbot --nginx -d portal.mywebsite.com:8888
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org
Obtaining a new certificate
An unexpected error occurred:
The request message was malformed :: Error creating new authz :: Invalid character in DNS name
NOTE:
I installed letsencrypt certificate on the same server, but to (portal.mywebsite.com) and it works fine.
this server has 2 projects, the first one on the 443 port, the second one on 4000 port.
the first one works correctly, but the second is not, what should I do?
Two projects, both with the same domain name? The port number is not a part of the hostname as previously mentioned and therefore is not relevant to the certificate creation.
Or, are there two different domains involved? If so, you will need either two different certificates or a certificate with a SAN depending upon how you wish to configure the webserver.
If they’re on the same domain name, the certificate you already got for port 443 should be equally valid for any other port. You don’t need to get a second certificate, you just need to configure the server on the other port to use the same certificate.