express 配置https
首先在阿里雲中配置好雲盾證書
privatekey.pem是私有鑰匙
certificate.pem是公有鑰匙
var fs=requires('fs');
var https=requires('https');
var app=express();
var privatekey = fs.readFileSync('privatekey.pem', 'utf8');
var certificate = fs.readFileSync('certificate.pem', 'utf8');
var options={key:privatekey, cert:certificate};
var server = https.createServer(options, app);
server.listen(443);
測試
app.get("/", function (req, res){
if (req.protocol == 'https'){
res.send('https');
}
});
相關文章
- weblogic配置httpsWebHTTP
- springboot 配置 httpsSpring BootHTTP
- gogs配置httpsGoHTTP
- Nginx配置HTTPSNginxHTTP
- Oracle 19c Database Configure the HTTPS Port for EM ExpressOracleDatabaseHTTPExpress
- 4.4 為CDB配置EM ExpressExpress
- 二、Nginx 配置 httpsNginxHTTP
- Express 配置HTML頁面訪問ExpressHTML
- Nginx配置Https專案NginxHTTP
- 配置HTTPS伺服器HTTP伺服器
- Nginx 配置https證書NginxHTTP
- 全站HTTPS升級系列(三)nginx配置全站HTTPSHTTPNginx
- Express搭建線上便利貼——Webpack配置ExpressWeb
- springboot部署到阿里雲,配置https,springboot專案同時支援http和https請求,阿里雲配置httpsSpring Boot阿里HTTP
- 阿里雲配置http轉https阿里HTTP
- Nginx如何配置HTTPS詳解NginxHTTP
- phpstudy apache 配置 https 證照PHPApacheHTTP
- nginx+php-fpm配置HTTPSNginxPHPHTTP
- Homestead 站點如何配置 httpsHTTP
- nginx docker容器配置https(ssl)NginxDockerHTTP
- HTTPS的SSL證書配置HTTP
- ubuntu16.04 lamp https配置UbuntuLAMPHTTP
- Express教程01:建立伺服器、配置路由Express伺服器路由
- HTTPS基礎原理和配置-3HTTP
- HTTPS基礎原理和配置 - 1HTTP
- HTTPS基礎原理和配置-2HTTP
- nginx配置https詳細過程NginxHTTP
- Nginx如何配置Http、Https、WS、WSS?NginxHTTP
- WebSphere配置https協議訪問WebHTTP協議
- nginx配置https協議訪問NginxHTTP協議
- Nginx使用SSL模組配置httpsNginxHTTP
- nginx 專案配置 https 訪問NginxHTTP
- Nginx配置網站預設httpsNginx網站HTTP
- centos nginx下配置免費httpsCentOSNginxHTTP
- linux環境使用Certbot配置httpsLinuxHTTP
- CAS單點登入-https配置HTTP
- nginx配置ssl加密(單/雙向認證、部分https) – HTTPS SSL 教程Nginx加密HTTP
- debian11 hexo+nginx 配置httpsHexoNginxHTTP
- Anolis8.6 hexo+nginx 配置httpsHexoNginxHTTP