K
K
kuzubina2020-06-27 13:40:09
Express.js
kuzubina, 2020-06-27 13:40:09

How to connect server on nodejs expressjs to https protocol?

Help plz figure out how to do it right?
There is a VDS server on Ubuntu 16.04, I launched my own server on it (while it works via http), bound the domain and installed the ssl certificate via certbot. The front is running VUE.JS on the domain and needs to make requests to my server to get info. The problem is that due to the fact that the site works on https and the server on http, the browser rejects such requests.
How can I configure my server to use the https protocol to work correctly?
I would appreciate any advice :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Albert Komarov, 2020-06-27
@kuzubina

You need to do this:
1. Install nginx on the server
2. Install certbot
3. At the stage of obtaining certificates using certbot, select the option - force redirect all requests to https.
4. In the nginx config settings, set the proxying of all calls to nodejs (see locations)
This is a best practice)

E
Eugene, 2020-06-27
@Nc_Soft

What's the point of doing it through node? Make everything work on http , and then just organize https through nginx (or cloudflare).
This is not the task of the application.

S
SagePtr, 2020-06-27
@SagePtr

I usually forward through nginx. The explanation is simple: on nodejs, I have several applications running on the server, and the 443rd port is the only one. Yes, and you can not add unnecessary layers of logic in the applications themselves, such as logging, working with certificates, and other things, if nginx handles this on its own, which facilitates both development and administration when all the logs are in one place in the same form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question