What is the difference between HTTP server and HTTPS considering my structure?

Asked

Viewed 37 times

1

I have a js Rest Node application running behind a proxy Reverse by Nginx, with https properly configured, where the server is configured as follows: Obs: app is my router.

const httpServer = http.createServer(app);
httpServer.listen(port, () => {
      console.log('hello');
});

And Nginx as proxy Reverse is set up as follows:

server {
    server_name example.com example.com.br;

    if ($host !~* example\.com$) {
        return 301 $scheme://example.com$request_uri;
    }

    location / {
    proxy_pass http://localhost:3003;
        proxy_buffering off;
        proxy_set_header Host $host;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com.br/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com.br/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com.br) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;
    server_name example.com example.virturian.com.br;
    return 404; # managed by Certbot
}

i can access the application quietly, everything is working perfectly, my question is, it is still necessary, considering a production environment, configure the express server as follows?

const httpsServer = https.createServer(credentials, app);
httpsServer.listen(port, () => {
  console.log('hello');
});

What is the difference between the two approaches, it is really necessary to already run https by Nginx, implement as httpsServer? Another question, I need to listen at door 443 with the second approach, or any other?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.