ssl - 在子域上使用 SSL 的 Azure 云服务

标签 ssl azure

我的 Azure 云服务设置如下:

<Sites>
  <Site name="Web" physicalDirectory="../SampleWebsite/">
    <Bindings>
      <Binding name="HttpIn" endpointName="HttpIn" />
    </Bindings>
  </Site>
  <Site name="Admin" physicalDirectory="../SampleWebsite/Admin">
    <VirtualApplication name="Admin" physicalDirectory="../SampleWebsite/Admin">
    <Bindings>
      <Binding name="HttpsIn" endpointName="HttpsIn"/>
    </Bindings>
  </Site>
</Sites>
<Endpoints>
  <InputEndpoint name="HttpIn" protocol="http" port="80" />
  <InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="www.domain.com" />
</Endpoints>
<Certificates>
  <Certificate name="www.domain.com" storeLocation="LocalMachine" storeName="My" />
</Certificates>

我试图要求 https://www.domain.com/Admin 使用 SSL目录。但是,此配置允许在没有 SSL 的情况下连接到此 URL。有没有办法在 Azure 中的子目录上要求 SSL?

最佳答案

如果您使用 MVC 并为您想要强制通过 SSL 的任何 Controller 和/或操作实现 [RequiresSSL] 属性,请使用 breischi 的答案。否则,您也可以使用 Url Rewrite 来完成任务(将规则添加到 web.config):

<rule name="Force HTTPS" enabled="true">
    <match url="^.*/Admin/(.*)$" ignoreCase="false" />
    <conditions>
        <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/Admin/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

关于ssl - 在子域上使用 SSL 的 Azure 云服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13771876/

相关文章:

azure - 无法正确理解事件中心消费者组的工作方式

azure - 从 Azure 上的 Linux 容器运行 Google Cloud Vision

user-interface - 私有(private) docker 注册表的用户界面

c# - WCF 新手 - 如何安装和使用 SSL 证书?

ios - 动态证书固定

azure - 无法从程序集“Microsoft.WindowsAzure.Storage,版本 = 4.3.0.0”加载类型 'Microsoft.WindowsAzure.Storage.Blob.CloudAppendBlob'

python - 如何为Python打包的libcrypto和libssl启用FIPS模式?

python - HSM 与 Python 请求模块的集成

mongodb - Azure 数据工厂中的条件映射

Azure,使用保留的IP地址创建VM,并将其放入用户子网中