asp.net-core - 如何忽略始终开启的 HTTPS Only Azure Appservice 自定义域设置
问题描述
我有一个作为 Azure AppService 运行的 ASP.Net Core 2.2 站点。作为配置的一部分,我有一个启用了仅 HTTPS设置的自定义域。
我还在我的 Appservice 上打开了Always on设置。
根据这篇文章 https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/仅开启HTTPS时将忽略Always on设置结果,我的网站总是在第一次通话时冷启动。
根据同一篇文章,可以在 web.config 中设置规则条件,如果处理了 {warmup_request} ,则不处理重定向到 HTTPS规则。
但是,我的HTTPS 仅设置在 Azure 中的自定义域上,而不是 web.config 中的规则。
我在 startup.cs 中使用以下代码设置 RouteOptions:
services.Configure<RouteOptions>(options =>
{
options.LowercaseUrls = true;
});
并相信规则条件也可以在这里完成,options.ConstraintMap()
但我不确定表示以下内容所需的语法或方法:
<match url="(.*)" />
<conditions>
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
<add input="{REMOTE_ADDR}" pattern="^100?\." negate="true" />
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
任何有关如何执行此操作的帮助将不胜感激
谢谢
解决方案
从撰写本文开始,“仅 https”已添加为应用服务的内置功能,因此不再需要使用此重写规则。
至于如何最小化您的应用程序的冷启动 - 您可能需要考虑将 appinit 配置添加到 web.config,如App Service Warm-Up Demystified中所述
推荐阅读
- asp.net - 模型绑定未执行
- node.js - 无法连接到 Node.js 中的事件桥
- sql - Microsoft SQL 和 SSAS 刚性关系
- java - 如何准备一个大的 txt 文件以使用 Hibernate 批量插入?
- sparql - sparql-gremlin:如何使用 java 实现相同的目标?
- tensorflow - 具有数据不平衡问题的二元分类损失函数
- pytorch - 如何制作火炬张量?
- node.js - Lambda:无法在 s3 中流式传输和上传数据
- javascript - 猫鼬模糊搜索不适用于 updateOne
- python - 从给定索引开始的列表中数字的总和,递归