在 IIS 使用 web.config 配置域名端口跳转

作者:V君 发布于:2020-2-9 0:21 Sunday 分类:小服杂记

— TL;DR —

按需将以下配置节点添加到 web.config ,修改目标域名,完成。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
 <security>
   <requestFiltering>
   <fileExtensions allowUnlisted="true">
    <remove fileExtension=".cs" />
   </fileExtensions>
  </requestFiltering>
 </security>
 <rewrite>
  <rules>
    <rule name="RedirectGogs" stopProcessing="true" enabled="true">
      <match url="^gogs/(.*$)" />
      <action type="Redirect" redirectType="Temporary" url="https://gogs.topcl.net:8443/{R:1}"/>
    </rule>

    <rule name="RedirectExaWww" stopProcessing="true" enabled="true">
      <match url="^(?![\._].*$).*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="www\.example\.com" />
      </conditions>
      <action type="Redirect" redirectType="Temporary" url="https://blog.example.com:8443/{R:0}"/>
    </rule>
    <rule name="RedirectExa" stopProcessing="true" enabled="true">
      <match url="^(?![\._].*$).*" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="example\.com" />
      </conditions>
      <action type="Redirect" redirectType="Temporary" url="https://blog.example.com:8443/{R:0}"/>
    </rule>

    <rule name="DefultRedirectBlog" stopProcessing="true" enabled="true">
      <match url="^(?![\._].*$).*" />
      <action type="Redirect" redirectType="Temporary" url="https://blog.topcl.net:8443/{R:0}"/>
    </rule>
  </rules>
 </rewrite>
</system.webServer>
</configuration>

— 听我扯扯 —

咋一看,不就是 rewrite + redirect (307) 不就好? 其实没有那么简单,比如源代码连接里以 .cs 后缀的代码文件 ()就在跳转的时候被 IIS 拦下来 404 了,因此还得额外加白。你可能会担心安全风险,但我这个空间仅仅用来跳转,根目录下只有这个 web.config 文件。

二月份的文章也只能这么水了,因为疫情只能把自己关在家

— 更新 —

将正则表达式改为 ^(?![\._].*$).* 可以忽略以指定字符开头的路径,方便申请 Let's 证书和临时放些文件,使配置更灵活

— 更新Ⅱ —

使用 conditions 实现别名支持,使空间变跳转 hub,将其利用价值榨干

标签: SSL证书 HTTPS ASP.NET IIS

评论(0) 引用(0) 浏览(957)

这下总算是彻底解决80端口封杀啦!

作者:V君 发布于:2013-7-30 16:53 Tuesday 分类:小服杂记

花了一天时间自己折腾

首先自行颁发不受信任的证书, 然后配置Apache2 SSL(这里花最多时间...), 外网访问测试

皆大欢喜! 狗日的电信没有封 HTTPS 443 端口!

接下来去狗爹买 SSL 证书, 本来想买子域名通配的, 但尼玛这要一千多太贵.... 

先弄个单域名的来玩玩吧 233~

证书签发/导入后, 看见地址栏的锁头有黄色三角形, 看来是emlog对HTTPS支持不够完善哇~ 

点击查看原图

啃代码, 发现页面上有http而不是https

用 grep 找到 function.base.php :: getBlogUrl , 嘿嘿.. 发现这里直接硬编码 http:// 啦

然后我也来硬fix这下地址栏的锁头变绿色啦 OhYeah!

点击查看原图

点击查看原图

点击查看原图

 

标签: 流氓ISP 端口封杀 SSL证书 HTTPS emlog

评论(0) 引用(0) 浏览(1581)

Powered by emlog 去你妹的备案 sitemap