I've got a node.js project running locally with http2 and https. Everything is running great, I generated a self signed cert and running the app serves everything up correctly. So now i'm trying to move it to my server, which is centos running nginx, and uses proxypass
to map http://myserverip:port
to http://example.com
. HTTP works fine and is currently running, but in my attempts to convert over to https, I haven't been able to get the site to display. Note that going to https://myserverip:port
works and serves everything up, so I believe this is isolated to my nginx config.
Here is my nginx conf for this site:
server
{
listen 80;
listen [::]:80;
server_name example.com www.example.com;
location /
{
proxy_pass http://127.0.0.1:3103;
include /etc/nginx/proxy_params;
}
}
server {
listen 443 ssl http2;
listen [::]:443;
server_name example.com www.example.com;
ssl_certificate /var/www/example.com/app/certs/example.crt;
ssl_certificate_key /var/www/example.com/app/certs/example.key;
location / {
proxy_pass https://127.0.0.1:3103;
}
}
In my nginx log i get the following error: no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking
. Seems wierd since i have the ssl_certificate
& ssl_certificate_key
set. One thing that does confuse me a bit is that my node server requires me to load a cert in the code, so it seems wierd to have to load the same cert twice? Here is the relevant code from my server so you can see what that is doing.
const spdyOptions = {
key: fs.readFileSync( path.resolve(__dirname, `../certs/${certName}.key`) ),
cert: fs.readFileSync( path.resolve(__dirname, `../certs/${certName}.crt`) )
}
// Export
module.exports = handle => {
const server = express()
server
// Frontend
.get('*', (req, res) => handle(req, res))
spdy
.createServer(spdyOptions, server)
.listen(cf.port, listen)
}
Hopefully something jumps out at you that i'm doing wrong... i'm fairly new to nginx so i could just be misunderstanding something easy. If you need any more info just ask! Thanks!