做好的网站模板怎么修改网络营销做的比较好的企业
在项目上本来一直使用的是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去访问
还可以用域名加端口去访问