只是用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. JQuery——相关练习

    ####JQuery的基本语法 <!--导入JQuery文件--> <script src="js/jquery-3.1.1.min.js"> /*带min ...

  2. Java——反射机制

    反射概念: Java反射是Java被视为动态(或准动态)语言的一个关键性质.这个机制允许程序在运行时透过Reflection APIs取得任何一个已知名称的class的内部信息,包括其modifier ...

  3. 提高效率的Linux命令

    提高效率的Linux命令 一.fc 二.disown 三.Ctrl + x +e 四.!! 两个感叹号 五.一次创建多个目录或文件 六.tee 七.删除从开头到光标处的命令文本 八.删除从光标到结尾处 ...

  4. Linux-apache httd.conf文件详解

    Linux-apache httd.conf文件详解 # This is the main Apache server configuration file. It contains the # co ...

  5. Hyperbase数据迁移

    原老集群有100台服务器,新增90台服务器和原来的服务器构成新Hyperbase集群最初考虑有两种方案distcp和snapshot,由于distcp进行数据迁移时不在HBase本身控制范围内,故选用 ...

  6. Manacher(马拉车)算法详解

    给定一个字符串,求出其最长回文子串 eg:  abcba 第一步: 在字符串首尾,及各字符间各插入一个字符(前提这个字符未出现在串里). 如  原来ma  /*  a    b a    b   c ...

  7. 2020第十一届蓝桥杯第二场省赛C++A组【A-H】

    A. 门牌制作 答案 624 代码 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_st ...

  8. dsu on tree ——附带buff的暴力解法

    这篇博客只是简单叙述思想(因为ML太弱了),具体例题请转其他博客. dsu on tree,许多OI将其归于启发式合并,当然如果你能理解更好,这只是一个理解方式罢了. 思想简述 顾名思义,这个算法是处 ...

  9. Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors

    B Equal Rectangles 题意: 给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等 题解: 原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个 ...

  10. 继承自List<T>的类通过NewtonJson的序列化问题

    什么问题? NewtonSoft.Json是我们最常用的Json组件库之一了.这里来讨论下使用NewtonSoft.Json序列化List<T>子类的情景.序列化使用了类JsonSeria ...