iis 具有 URL 重写 v2 和应用程序请求路由的反向代理

19 篇文章 0 订阅
6 篇文章 0 订阅

官方文档

微软官方文档地址:https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing

模块下载

iis 重写下载模块地址: https://www.iis.net/downloads/microsoft/url-rewrite
安装后会有这个模块
请添加图片描述

iis 部署 django + vue (使用反向代理实现服务器对外只暴露一个端口)
例:
服务器 windows server 2019
对外暴露 端口:8001
django端口:8000
vue端口:8002
按照官方文档的demo测试一遍没问题。
在服务器尝试仍然报 404 。

发现 vue 的 js 404
解决方法:
iis重写url 里 添加vue打包后js,css,fonts,img路径

django 报404 仍未想明白
可能和下面一些操作有关(实在是不想在捣鼓它了,折磨人)

1.添加功能后重启
请添加图片描述
多出了下面的文件,本来没有这些文件
请添加图片描述
添加功能如下(有些功能也不知道具体啥作用,加就完了)
服务器角色
请添加图片描述
功能
请添加图片描述

请添加图片描述

请添加图片描述

最后web.config 配置

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Reverse Proxy to account" stopProcessing="true">
                    <match url="^account/(.*)" />
                    <action type="Rewrite" url="http://localhost:8000/{R:0}" />
                </rule>
	<rule name="Reverse Proxy to api" stopProcessing="true">
                    <match url="^api/(.*)" />
                    <action type="Rewrite" url="http://localhost:8000/{R:0}" />
                </rule>
                <rule name="Reverse Proxy to vue" stopProcessing="true">
                    <match url="^login/(.*)" />
                    <action type="Rewrite" url="http://localhost:8002/{R:1}" />
                </rule>
	<rule name="Reverse Proxy to vuejs" stopProcessing="true">
                    <match url="^js/(.*)" />
                    <action type="Rewrite" url="http://localhost:8002/{R:0}" />
                </rule>
	<rule name="Reverse Proxy to vuescc" stopProcessing="true">
                    <match url="^css/(.*)" />
                    <action type="Rewrite" url="http://localhost:8002/{R:0}" />
                </rule>
	<rule name="Reverse Proxy to vueexcel" stopProcessing="true">
                    <match url="^excel/(.*)" />
                    <action type="Rewrite" url="http://localhost:8002/{R:0}" />
                </rule>
	<rule name="Reverse Proxy to vuefonts" stopProcessing="true">
                    <match url="^fonts/(.*)" />
                    <action type="Rewrite" url="http://localhost:8002/{R:0}" />
                </rule>
	<rule name="Reverse Proxy to vueimg" stopProcessing="true">
                    <match url="^img/(.*)" />
                    <action type="Rewrite" url="http://localhost:8002/{R:0}" />
                </rule>
                <rule name="static" stopProcessing="true">
                    <match url="^static(.*)" />
                    <action type="Rewrite" url="http://localhost:8000/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值