只是用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的更多相关文章

  1. Nginx设置Https反向代理,指向Docker Gitlab11.3.9 Https服务

    目录 目录 1.GitLab11.3.9的安装 2.域名在阿里云托管,申请免费的1年证书 3.Gitlab 的 https 配置 4.Nginx 配置 https,反向代理指向 Gitlab 配置 目 ...

  2. 设置https以及http转https的问题

    公司用的是阿里云服务器win2008server r2 ,环境是phpwamp,出现许多问题.2018-11-12 一 设置https 1.设置httpd.ini 取消以下三个配置的# LoadMod ...

  3. 码云私人代码 SSH 设置----https://blog.csdn.net/kkaazz/article/details/78667573

    码云私人代码 SSH 设置 https://blog.csdn.net/kkaazz/article/details/78667573

  4. Golang设置https访问,以及http如何重定向到https

    设置https访问: 原始代码为http监听: func main() { server := &http.Server{ Addr: ":8080", ... } go ...

  5. flask 设置https请求 访问flask服务器

    学习过程中想要学教程中一样,做个假的微信公众号推送,不过去了微信开发文档怎么一直说需要https的请求(教学中没有说需要https,一直是http) 但是我的服务器只能使用http请求访问,如果硬是要 ...

  6. Nestjs 设置静态文件,public

    Docs: https://docs.nestjs.com/techniques/mvc main.js import { NestFactory } from '@nestjs/core'; imp ...

  7. httpd设置HTTPS双向认证

    去年用tomcat.jboss配置过HTTPS双向认证,那时候主要用的是JDK自带的keytool工具.这次是用httpd + openssl,区别比较大 在网上搜索了很多文章,发现全面介绍的不多,或 ...

  8. Charles设置HTTPS抓包

    1. 配置 Charles 根证书 点击 Help -> SSL Proxying -> Install Charles Root Certificate 之后会弹出钥匙串,如果不弹出,请 ...

  9. 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 查看系统 ...

随机推荐

  1. vue组件中data为什么必须是一个函数?

    因为JavaScript的特性所导致,在component中,data必须以函数的形式存在,不可以是对象. 组建中的data写成一个函数,数据以函数返回值的形式定义,这样每次复用组件的时候,都会返回一 ...

  2. Integer的十进制转二,八,十六进制

    1,toBinaryString(int i) 将i以二进制形式输出出来 2,toOctalString(int i)将i以八进制形式输出出来 3,toHexString(int i)将i以十六进制形 ...

  3. 二:SpringBoot-配置Log4j2,实现不同环境日志打印

    SpringBoot-配置Log4j2,实现不同环境日志打印 日志打印之外观模式 1.日志配置 2.Log4j2的配置文件 3.简单的测试程序 日志打印之外观模式 每一种日志框架都有自己单独的API, ...

  4. 编写高性能Java代码的最佳实践

    博客地址: http://blog.csdn.net/dev_csdn/article/details/79033972

  5. JSP标签使用的代码记录——《%= %》(神奇的CSDN为啥标题不让打英文的尖括号)

    关于JSP的一些标签,在用到的时候有些生疏,就去找了找资源重新温习了一下. 附上两个JSP<%= %>标签的博客,同时也记录当前项目里用到的方法. jsp页面中<%@ %>.& ...

  6. Linux和Xshell安装

    Linux安装 开启虚拟机 选择语言 软件选择 点击软件→软件选择→基础设施服务器 安装位置 网络连接 开始安装 设置root密码 建议设置成root,因为密码忘了改起来很麻烦 登录 查看IP Xsh ...

  7. Java 复习整理day04

    在我们的日常生活中,方法可以理解为要做某件事情, 而采取的解决办法. 如:小明同学在路边准备坐车来学校学习.这就面临 着一件事情(坐车到学校这件事情)需要解决,解决办法 呢?可采用坐公交车或坐出租车的 ...

  8. 织梦dedecms用户注册时笔名去掉的方法

    修改目的:用户注册时不用输入笔名,实现系统自动同步用户名和用户笔名. 负责织梦dedecms用户注册的php文件是member/reg_new.php ,不难发现,用户注册时的用户名$userid,和 ...

  9. AtCoder Beginner Contest 188 C - ABC Tournament (模拟)

    题意:有\(2^n\)个人站成一排比赛,刚开始每个人都和自己右边的人进行比赛,赢得人晋级下一轮(下标的小的在前面),不断重复这个过程,问最后拿到第二名的人的编号. 题解:根据题意,可以用vector直 ...

  10. uestc 1221 Ancient Go

    Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit  Status Y ...