Nestjs 设置https
只是用https
import * as fs from 'fs';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
const httpsOptions = {
key: fs.readFileSync('D:/localhost_ssl/dev.ajanuw.com.key'),
cert: fs.readFileSync('D:/localhost_ssl/dev.ajanuw.com.crt'),
};
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
httpsOptions,
});
app.enableCors();
// 我配置了hosts文件,让dev.ajanuw.com指向127.0.0.1
console.log(`https://dev.ajanuw.com:3000/`);
await app.listen(3000);
}
bootstrap();
http和https
import * as fs from 'fs';
import * as http from "http";
import * as https from "https";
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as express from 'express';
import { ExpressAdapter } from '@nestjs/platform-express';
const httpsOptions = {
key: fs.readFileSync('D:/localhost_ssl/dev.ajanuw.com.key'),
cert: fs.readFileSync('D:/localhost_ssl/dev.ajanuw.com.crt'),
};
async function bootstrap() {
const server = express();
const app = await NestFactory.create(
AppModule,
new ExpressAdapter(server)
);
app.setGlobalPrefix('api');
app.enableCors();
await app.init();
console.log(`http://dev.ajanuw.com:3000`);
console.log(`https://dev.ajanuw.com`);
http.createServer(server).listen(3000);
https.createServer(httpsOptions, server).listen(443);
}
bootstrap();
如果要访问http:http://dev.ajanuw.com:3000,https:https://dev.ajanuw.com
Nestjs 设置https的更多相关文章
- Nginx设置Https反向代理,指向Docker Gitlab11.3.9 Https服务
目录 目录 1.GitLab11.3.9的安装 2.域名在阿里云托管,申请免费的1年证书 3.Gitlab 的 https 配置 4.Nginx 配置 https,反向代理指向 Gitlab 配置 目 ...
- 设置https以及http转https的问题
公司用的是阿里云服务器win2008server r2 ,环境是phpwamp,出现许多问题.2018-11-12 一 设置https 1.设置httpd.ini 取消以下三个配置的# LoadMod ...
- 码云私人代码 SSH 设置----https://blog.csdn.net/kkaazz/article/details/78667573
码云私人代码 SSH 设置 https://blog.csdn.net/kkaazz/article/details/78667573
- Golang设置https访问,以及http如何重定向到https
设置https访问: 原始代码为http监听: func main() { server := &http.Server{ Addr: ":8080", ... } go ...
- flask 设置https请求 访问flask服务器
学习过程中想要学教程中一样,做个假的微信公众号推送,不过去了微信开发文档怎么一直说需要https的请求(教学中没有说需要https,一直是http) 但是我的服务器只能使用http请求访问,如果硬是要 ...
- Nestjs 设置静态文件,public
Docs: https://docs.nestjs.com/techniques/mvc main.js import { NestFactory } from '@nestjs/core'; imp ...
- httpd设置HTTPS双向认证
去年用tomcat.jboss配置过HTTPS双向认证,那时候主要用的是JDK自带的keytool工具.这次是用httpd + openssl,区别比较大 在网上搜索了很多文章,发现全面介绍的不多,或 ...
- Charles设置HTTPS抓包
1. 配置 Charles 根证书 点击 Help -> SSL Proxying -> Install Charles Root Certificate 之后会弹出钥匙串,如果不弹出,请 ...
- Mysql Innodb 性能参数设置 https://www.rathishkumar.in/2017/01/how-to-allocate-innodb-buffer-pool-size-in-mysql.html
参考原文: https://www.rathishkumar.in/2017/01/how-to-allocate-innodb-buffer-pool-size-in-mysql.html 查看系统 ...
随机推荐
- 使用nodejs构建Docker image最佳实践
目录 简介 准备nodejs应用程序 创建Dockerfile文件 创建.dockerignore文件 创建docker image 运行docker程序 node的docker image需要注意的 ...
- Java 从Character和char的区别来学习自动拆箱装箱
本文结构 1.Character和char 的区别: 2.自动拆箱装箱 1.Character和char 的区别: Character是类,char基本数据类型. 在java中有三个类负责对字符的操作 ...
- 本地代码上传GitHub
0. 登录 git config --global user.name "GitHub用户名" git config --global user.email "GitHu ...
- Oracle数据库查询锁表及解锁
一.查询哪些表被锁以及查看锁表得会话及操作系统进程ID 其中locked_mode为锁的级别,spid为数据库所在操作系统的进程id select c.sid, c.serial#, c.userna ...
- MTO1804无刷电机引发的悲惨经历之二:电调固件刷新与优化
前言 原创文章,转载引用请务必注明链接,水平有限,如有疏漏,欢迎指正. 书接上回,我们总算是基本确认了黑衣神秘电调的身份,本文就尝试对电调固件进行一番设置,来个免费优化. 1.刷新固件 关于电调的固件 ...
- RESTFul应用分析
Restful API 近年来应用越来越广泛,各大互联网公司纷纷推出了自己的 Restful API 服务. 本文将从实际应用出发,从 REST 到 Restful 再到 Restful API ,逐 ...
- linux 用户、用户组及相关命令(useradd 、passwd、userdel 、groupadd 、groupdel、usermod 、gpasswd 、 id、su)
linux是一个多用户系统,用于权限管理(权限最小化); 相关命令: 7 8 9 10 11 12 13 14 15 useradd passwd userdel groupadd groupdel ...
- 腾讯云TcaplusDB获新加坡MTCS最高等级安全认证
近日,经过国际权威认证机构DNV GL的全面评估审核,TcaplusDB获得了新加坡多层云安全(以下简称"MTCS")T3级最高等级认证,这标志着TcaplusDB全面满足了新加坡 ...
- 最好的IDEA debug长文?看完我佛了
前言 你好,我是A哥(YourBatman). 最近写了几篇IntelliJ IDEA系列的文章,反响蛮好.我想了下,因为并非是分享什么破解方法.推荐插件.主题这种蛋炒饭式哗众取宠的文章,而是真实对工 ...
- Codeforces #6241 div2 C. Orac and LCM (数学)
题意:给你一个数列,求所有子序列对的\(lcm\),然后求这些所有\(lcm\)的\(gcd\). 题解:我们对所有数分解质因数,这里我们首先要知道一个定理: 对于\(n\)个数,假如某个质数\( ...