Hussain Mirahmadi Hussain Mirahmadi - 2 months ago 28
HTTP Question

http to a Node server over https nginx website

Is it possible to have a http connection to a node.js server over a website which is generally secured by https ?

how do you suggest to combine a node connection with a website that is operating on https .

Answer

As already mentioned in the comments, it is useful to create a proxy to your node.js applications. A good tutorial is, for instance, from DigitalOcean: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04

In this tutorial, it shows that the host configuration can look like this:

server {
    listen 80;

    server_name example.com;

    location / {
        proxy_pass http://APP_PRIVATE_IP_ADDRESS:8080;
        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;
    }
}

In this case, a reverse proxy to the port 8080 was created. Generally, this method can be used for every node.js application.

In your case: add the location block in your https server block and modify the route.