【应用服务 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的词就是反向 ...
随机推荐
- 005.操作系统及Linux系统,虚拟机的作用和发展历史
操作系统及其作用 操作系统发展史 Linux系统 虚拟机 操作系统 操作系统 操作系统的作用 不同领域的主流操作系统 操作系统(Operation System,OS) 操作系统作为接口的示意图 没有 ...
- Shell学习(一)认识Shell
一.啥是Shell Shell : 一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 既是一种命令语言,又是一种程序设计语言. Shell脚本 : 一种为 shell 编写的 ...
- python环境变量的安装与配置
安装最新的3.x(2.x如今已经不常见) 下图来源:百度(电脑已安装,不能重复) 一定要勾选"Add Python 3.6 to PATH".(如果没有勾选在安装完成后需要手动添加 ...
- Kafka和RocketMQ底层存储之那些你不知道的事
大家好,我是yes. 我们都知道 RocketMQ 和 Kafka 消息都是存在磁盘中的,那为什么消息存磁盘读写还可以这么快?有没有做了什么优化?都是存磁盘它们两者的实现之间有什么区别么?各自有什么优 ...
- Oracle 11gR2
OracleOraDb11g_home1TNSListener #其它客服端连接需要开启服务,如不开启,本机连接可以直接使用sqlplus OracleServiceORCL #实例SID服务 sq ...
- .Net Core 2.2 存取Cookie
第一步(注释代码):注释Startup.cs中 ConfigureServices 函数中的 options.CheckConsentNeeded = context => true; 第二步 ...
- aarch64架构移动设备挂载移动硬盘
添加yum源 wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 安装ntfs yum inst ...
- Layman 解决MUI 软键盘弹起挤压页面问题
问题:在使用mui和H5+进行移动端开发的时候,经常会遇见需要用户输入的情况 当input获取焦点弹起软键盘的时候,经常会遇见软键盘挤压页面.软键盘遮挡输入框等一系列问题: 原因:造成这种现象的原因是 ...
- .NET Standard 简介
系列目录 [已更新最新开发文章,点击查看详细] .NET Standard 是一套正式的 .NET API 规范,有望在所有 .NET 实现中推出. 推出 .NET Standard 的背后动 ...
- sqlserver 分列
sql server 数据库中某张表(Person)的数据信息是: ID Address 1 平山花园-4单元-12幢-203 2 香山花园-3单元-22幢-304 现在有需求是,将地址信息显示形式改 ...