当前位置: 首页 > news >正文

abp vnext4.3版本托管到iis同时支持http和https协议

在项目上本来一直使用的是http协议,后来因为安全和一些其他原因需要上https协议,如果发布项目之后想同时兼容http和https协议需要更改一下配置信息,下面一起看一下:

1.安装服务器证书

首先你需要先申请一张服务器证书,申请后将证书安装到服务器上(也可以在iis中选择服务器证书导入)。

直接安装到服务器的方式
在这里插入图片描述

或者在iis中导入服务器证书
在这里插入图片描述
在这里插入图片描述

2.修改appsettings.json文件

添加Urls节点:节点中配置http端口和https端口
App节点中的地址默认为localhost就可以

{"App": {"SelfUrl": "http://localhost:44386", "CorsOrigins": "https://*.aaa.com,http://localhost:4200,https://localhost:44307,http://localhost:8080,http://192.168.0.86:8080","RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307"},"ConnectionStrings": {  "Default": "Server=111.111.11.11; Database=Test; Persist Security Info=True;User ID=sa;Password=123;Packet Size=512;"},"Redis": {"RedisConnectionString": "111.111.11.11:6379,password=12312312313,ConnectTimeout=15000,SyncTimeout=5000"},"AuthServer": {"Authority": "http://localhost:44386","RequireHttpsMetadata": "false","SwaggerClientId": "Test_Swagger","SwaggerClientSecret": "1123"},"StringEncryption": {"DefaultPassPhrase": "paaaaaaa"},"Urls": {"Http": {"Host": "localhost","Port": 44386},"Https": {"Host": "localhost","Port": 447}},"Settings": {"Abp.Mailing.Smtp.Host": "127.0.0.1","Abp.Mailing.Smtp.Port": "25","Abp.Mailing.Smtp.UserName": "","Abp.Mailing.Smtp.Password": "","Abp.Mailing.Smtp.Domain": "","Abp.Mailing.Smtp.EnableSsl": "false","Abp.Mailing.Smtp.UseDefaultCredentials": "true","Abp.Mailing.DefaultFromAddress": "noreply@abp.io","Abp.Mailing.DefaultFromDisplayName": "ABP application","Abp.Identity.Lockout.MaxFailedAccessAttempts": 20,"Abp.Identity.Lockout.LockoutDuration": 180,//"Abp.Identity.Password.RequiredUniqueChars": false,"Abp.Identity.Password.RequireNonAlphanumeric": false,//"Abp.Identity.Password.RequireLowercase": false,"Abp.Identity.Password.RequireUppercase": false,"Abp.Identity.Password.RequireDigit": false}
}

3.修改Program.cs文件

把http和https的地址和端口配置到webBuilder.UseUrls(“http://localhost:44386”, “https://localhost:447”).UseStartup();

internal static IHostBuilder CreateHostBuilder(string[] args) =>Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>{webBuilder.UseUrls("http://localhost:44386", "https://localhost:447").UseStartup<Startup>();}).UseAutofac().UseSerilog();

4.发布到iis配置http和https端口

在绑定https协议时SSL证书需要选择第一步导入的证书

如果你的域名绑定了ip
那么你既可以用http的IP去访问
也可以用https的IP去访问
还可以用域名加端口去访问
在这里插入图片描述

http://www.lryc.cn/news/101646.html

相关文章:

  • 2023年全网电视盒子无线ADB修改桌面(无需ROOT)
  • 什么是Java中的Maven?
  • 【C++】总结7
  • 【前端知识】React 基础巩固(四十二)——React Hooks的介绍
  • adb命令丨adb push命令大全_adb操控手机和指令
  • 【腾讯云 Cloud Studio 实战训练营】沉浸式体验编写一个博客系统
  • 手机视频聊天分享
  • 神经网络小记-优化器
  • 200+行代码写一个简易的Qt界面贪吃蛇
  • redis中使用bloomfilter的白名单功能解决缓存穿透问题
  • Spring Boot 2.7.8以后mysql-connector-java与mysql-connector-j
  • 03|「如何写好一个 Prompt」
  • 关于提示词 Prompt
  • 【Linux多线程】线程的互斥与同步(附抢票案例代码+讲解)
  • ajax概述
  • 小白带你学习linux的mysql服务(主从mysql服务和读写分离三十一)
  • 【低代码专题方案】iPaaS运维方案,助力企业集成平台智能化高效运维
  • Android SDK 上手指南||第一章 环境需求||第二章 IDE:Eclipse速览
  • Amazon Linux上使用ec2-user来设置开机自启动的shell脚本
  • 【Spring】Spring 下载及其 jar 包
  • 蓝桥杯2023年第十四届省赛-飞机降落
  • STM32 串口实验(学习一)
  • 多臂治疗规则的 Qini 曲线(Stefan Wager)
  • NOSQL之Redis配置及优化
  • 植物一区HR | 植物生理组+转录组:揭示豆科植物响应干旱胁迫机制
  • TCP粘包问题
  • QT【day1】
  • 【Golang】Golang进阶系列教程--为什么 Go 不支持 []T 转换为 []interface
  • 两数相加 II——力扣445
  • js获取上传视频的封面第一帧