Home > Web Front-end > JS Tutorial > body text

Detailed practical explanation of enabling HTTPS in Node.js

高洛峰
Release: 2016-12-09 09:58:11
Original
1539 people have browsed it

1. First, go to Tencent Cloud to apply

Detailed practical explanation of enabling HTTPS in Node.js

After the application is successful, you can directly download the certificate and use it.

Detailed practical explanation of enabling HTTPS in Node.js

2. Configure nginx

Add your domain name configuration under /etc/nginx/conf.d/ such as xxx.com.conf, the content is as follows

server {
  listen 80;
  listen 443 ssl;
  server_name www.xxx.com;
  ssl_certificate /etc/nginx/ssl/www.xxx.com_cert.crt;
  ssl_certificate_key /etc/nginx/ssl/www.xxx.com.key;
  location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass     http://127.0.0.1:8360;
  }
}
Copy after login

proxy_pass is the reverse proxy to The address of your node service.

sslcertificate and sslcertificate_key need to specify the certificate directory file, that is, copy the file you downloaded to the /etc/nginx/ssl directory.

3. Finally, just restart nginx. It's very simple.

Note The trouble comes when switching to https. https does not allow loading requests for http resources, so it is best to replace those addresses to support https.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template