【应用服务 App Service】 App Service Rewrite 实例 - 反向代理转发功能
问题描述
在使用Azure App Service(应用服务)时,有时候需要在不同的站点之间进行跳转,但是希望通过通过访问同一个域名的方式来实现反向代理。如果创建应用时候选择的是Window服务,这时候可以参考以下的方式配置IIS 的Proxy + Rewrie
如网站一为PHP站点,它的首页是:https://lbphptest.chinacloudsites.cn/, 网站二是Java站点,它的首页是:https://lbjavatest.chinacloudsites.cn/
|
站点一:PHP
|
站点二:JAVA
|
在使用反向代理后,在站点一种配置Proxy代理后,请求就会发送到Java站点,但是URL显示的依旧为PHP站点地址。

设置步骤
一: 准备好两个App Service站点
二:在需要做方向代理的站点种添加applicationHost.xdt和web.config 文件,如以上的例子中使用的是PHP站点作为代理站点。
- 添加ApplicationHost.xdt文件,开启Proxy enable属性为true。文件需要添加在D:\home\site下,与wwwroot目录同级

ApplicationHost.xdt的内容为:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />
</system.webServer>
</configuration>
- 添加web.config文件,设置rewrite的规则。

web.config的内容为(高亮部分即为需要配置的跳转站点):
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Proxy" stopProcessing="true">
<match url="^proxy/?(.*)" />
<action type="Rewrite" url="http://lbjavatest.chinacloudsites.cn/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
注:完成以上步骤后,需要重启PHP站点。
参考资料
Web 应用如何实现反向代理转发功能:https://docs.azure.cn/zh-cn/articles/azure-operations-guide/app-service-web/aog-app-service-web-howto-realize-reverse-proxy-and-forward-function
URL Rewrite Module Configuration Reference:https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#redirect-action
Rewrite Rules Overview
A rewrite rule defines the logic of what to compare or match the request URL with, and what to do if the comparison is successful.
Rewrite rules consists of the following parts:
- Pattern – The rule pattern is used to specify either the regular expression or a wildcard pattern that is used to match URL strings.
- Conditions – The optional conditions collection is used to specify additional logical operations to perform if a URL string matches the rule pattern. Within the conditions, you can check for certain values of HTTP headers or server variables, or verify if the requested URL corresponds to a file or directory on a physical file system.
- Action – The action is used to specify what to do if the URL string matches the rule pattern and all the rule conditions are met.
【应用服务 App Service】 App Service Rewrite 实例 - 反向代理转发功能的更多相关文章
- Nginx配置实例-反向代理实例:根据访问的路径跳转到不同端口的服务中
场景 Ubuntu Server 16.04 LTS上怎样安装下载安装Nginx并启动: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/detai ...
- upstream模块实现反向代理的功能
nginx平台初探(100%) — Nginx开发从入门到精通 http://tengine.taobao.org/book/chapter_02.html#id6 nginx的模块化体系结构¶ ng ...
- 记录Nginx实现内容重定向的两种方式:rewrite和反向代理
第一种:rewrite server { listen 80; server_name www.test.org; root /te ...
- nginx之rewrite重写,反向代理,负载均衡
rewrite重写(伪静态): 在地址栏输入xx.com/user-xxx.html, 实际上访问的就是xxx.com/user.php?id=xxx rewrite就这么简单 附上ecshop re ...
- Nginx配置实例-反向代理实现浏览器请求Nginx跳转到服务器某页面
场景 Ubuntu Server 16.04 LTS上怎样安装下载安装Nginx并启动: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/detai ...
- nginx 配置实例-反向代理
反向代理实例一 虚拟机IP:192.168.116.129实现效果:使用 nginx 反向代理,访问 www.123.com 直接跳转到 虚拟机的192.168.116.129:8080 实验代码 ...
- Nginx 笔记(三)nginx 配置实例 - 反向代理、负载均衡、动静分离
个人博客网:https://wushaopei.github.io/ (你想要这里多有) 一.反向代理 反向代理准备工作: (1)在 liunx 系统安装 tomcat,使用默认端口 8080 ...
- nginx证书制作以及配置https并设置访问http自动跳转https(反向代理转发jboss)
nginx证书制作以及配置https并设置访问http自动跳转https 默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译时指定–with-http_ssl_module参数,安装模块依赖 ...
- 【转】Nginx反向代理转发tomcat
http://blog.csdn.net/mlc1218559742/article/details/53117520 最近刚接触nginx,在网上查阅了相关资料,看到最多的形容nginx的词就是反向 ...
随机推荐
- 【转】Locust性能-零基础入门系列(1)-wait_time属性用法
本篇文章,从局部出发,利用一个简单的测试,来说明场景模拟的wait_time属性的用法.wait_time为什么要单独拎出来讲,是因为它主要有两种模式,而初学者对这两种模式,容易混淆.1) wait_ ...
- 原子类CAS的底层实现
原子类使用 public class CASDemo { public static void main(String[] args) { AtomicInteger atomicInteger = ...
- el-table行点击事件row-click与列按钮事件冲突
需求简述 表格用el-table实现,操作列的编辑按钮点击事件正常实现.现要为行加一点击事件,即row-click.加上后,发现点击操作列的编辑按钮时,会触发按钮本身事件,同时会触发行点击事件.第一版 ...
- pwnable.kr-blackjack-witeup
这是个人对程序逻辑的分析总结. 真的很巧很神奇,理解完程序的逻辑,不知道怎么破解.看了一眼题解,忽然懂了,好神奇哦. 题目说,要获得1000000才能获得flag.经过多次试玩和在分析程序的逻辑,知道 ...
- PostgreSQL数组类型应用
在使用 awk 脚本:数组是一大利器:在很多场景是用数组能处理. 在 python 中,数据类型list:相当于array类型. 在 Oracle 中,对 array 不够友好,感觉像是鸡肋.但是在 ...
- zabbix_server.conf配置文件参数
NodeID: 在amster-child 的分布式架构中,这个ID是唯一标识zabbix node的号码 ListenPort:Trapper 类型Item监听的端口, SourceIP: 在连接其 ...
- (转)ServletConfig与ServletContext
出处:http://blog.csdn.net/cl05300629/article/details/9362601 作者:伫望碧落 一.Servlet配置对象(ServletConfig):Serv ...
- MySQL 5.7 InnoDB锁
简介 参考https://dev.mysql.com/doc/refman/5.7/en/innodb-locking.html#innodb-gap-locks. InnoDB引擎实现了标准的行级别 ...
- NodeJS二进制合并
Node.js 批量文件合并code cnblogs @ Orcim 本 文主要介绍使用 Node 进行 ACB 序列文件(Atom CueSheet Binary,编译 AtomCueSheet ...
- TTL和CMOS电平
参考: 1.https://baike.baidu.com/item/TTL%E7%94%B5%E5%B9%B3/5904345 2.https://baike.baidu.com/item/CMOS ...

