How to create websocket secure by using NodeJS

Method 1:

In this article: How to run a https website with Nodejs, express and

Method 2: use NGINX

file .conf

upstream myapp1{

server {
    listen 443;

    ssl on;
ssl_certificate /etc/letsencrypt/live/; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/; # managed by Certbot
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    location / {
            access_log off;
			proxy_pass http://myapp1;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 86400;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";


Now, you can use websocket to create websocket secure:
Read more:
Example chat application using Nodejs +
Example chat application using Nodejs + ws
Example chat application using Nodejs + Websocket

Leave a Reply