How to enable the https in a node server? Then talk to the server use https?


#1

How to enable the https in a node server? Then talk to the server use https ?

Like https://sdk-mainnet.aepps.com , not like this http://sdk-mainnet.aepps.com

Thank you !


#2

Hi there,

We do this by putting an http server (in this case nginx) in front of the node. We can send you a sample config if you like.

j


#3

Hi @jsnewby, nginx is Ok, I would like it. thank you very much.


#4

One very easy solution, using let’s encrypt automatically for obtaining a certificate would be using Caddyserver:

Create a configuration file named Caddyfile with this content

https://mydomain.com {
    proxy / http://NODE_IP:3013
    proxy /v2/debug http://NODE_IP:3113
}

run the caddy binary in the same folder and it will automatically request a new certificate and proxy the node via https.

Otherwise for nginx you can follow the guide to obtain let’s encrypt certificates from here
and add a proxy to the (suggested) configuration:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;
    server_name  example.com www.example.com;

    listen 443 ssl; # managed by Certbot

    # RSA certificate
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot

    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

    # Redirect non-https traffic to https
    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    # 
    # Section to proxy the requests to a node
    # 
    location / {
      proxy_redirect off;
      proxy_set_header host $host;
      proxy_set_header X-real-ip $remote_addr;
      proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
      proxy_pass http://NODE_IP:3013;
    }

    location /v2/debug {
      proxy_redirect off;
      proxy_set_header host $host;
      proxy_set_header X-real-ip $remote_addr;
      proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
      proxy_pass http://NODE_IP:3113;
    }

}

#5

Thank you very much!


#6

when you get an issue with you website. dont’ be worry about it just contact see our site which
provide the solution related to the website server down or any issue contact by email.