To begin with - I'm really new to this stuff. I want to get ssl certificates for the webapp I'm working on. I look forward to any advices. Using Ubuntu 20.04
So here's the structure:
I'm using Nginx for providing my frontend on port 80 listening to my specified server_name (domain name of the server).
The node.js backend is running with pm2 on the IP address of the server on port 60702.
What I've tried:
I tried to get certificates from letsencrypt and got them ready for my frontend like it was described here digitalocean:
server{
# SSL configuration
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
# Path to certificates and configuration
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
...
In vue config I set https to true:
module.exports = {
baseUrl: './',
devServer: {
port: 8080,
https: true,
disableHostCheck: true
}
};
The problem was in my backend. I tried it like:
https.createServer({
key: fs.readFileSync('certs/selfsigned.key', 'utf8'),
cert: fs.readFileSync('certs/selfsigned.crt', 'utf8'),
//key: fs.readFileSync('certs/key.pem', 'utf8'),
//cert: fs.readFileSync('certs/cert.pem', 'utf8'),
rejectUnauthorized: false
}, app)
.listen(nconf.get('port'), function() {
console.log(`App listening on port ${nconf.get('port')}! Go to https://MY_IP:${nconf.get('port')}/`)
});
But I read here: letsencrypt on IP addresses that letsencrypt doesn't provide certificates on IP addresses.
So how can I get certificates for my application then? How would I do it properly?
Do I need to link certificates to front- and backend?