【应用服务 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的词就是反向 ...
随机推荐
- 中间件、蓝图、g对象
中间件 ''' flask中一旦请求到来,要执行app()--->>>执行的是app.__call__,整个flask的入口 ''' from flask import Flask ...
- API测试-接口测试基础(1)
由于自己想学习API方面的测试,但是市面上搜不到相关的图书可以系统学习,网上的内容又零零散散,适合有点API开发基础的人去搜索.为了方面新手学习API测试,现在整理了他人的宝贵经验和自己的学习心得,尽 ...
- SQL Server通过创建临时表遍历更新数据
前言: 前段时间新项目上线为了赶进度很多模块的功能都没有经过详细的测试导致了生成环境中的数据和实际数据对不上,因此需要自己手写一个数据库脚本来更新下之前的数据.(线上数据库用是SQL Server20 ...
- 【FLASK】钩子函数的使用
from flask import Flask from flask import abort app = Flask(__name__) # 在第一次请求之前调用,可以在此方法内部做一些初始化操作 ...
- http(Hyper Text Transfer Protocol)
一.定义 http(Hyper Text Transfer Protocol):超文本传输协议二.作用 数据传输三.概念 HTTP消息: 1.客户端发向服务器的请求消息 ...
- JavaScript,你好!
初识JavaScript 概述 JavaScript是一门世界上最流行的脚本语言 ECMAScript它可以理解为是javaScript的一个标准 而且现在最新的版本已经到es6版本 但是大部分浏览器 ...
- Kafka监控必备——Kafka-Eagle 2.0.2正式发布
对于经常使用Kafka的同学,拥有一个炫酷又实用的监控系统是非常有必要的.可以实时的监控数据流的情况,了解实时数据流的变化. Kafka Eagle Kafka Eagle是一个监控系统,监控Kafk ...
- Python 为什么不支持 switch 语句?
本文出自"Python为什么"系列,请查看全部文章 在这篇文章里,我们会聊一聊为什么 Python 决定不支持 switch 语句. 为什么想要聊这个话题呢? 主要是因为 swit ...
- fastjson配置序列化过滤转换
@Configuration@EnableWebMvcpublic class WebConfig implements WebMvcConfigurer { @Override public voi ...
- Java基础系列-SPI你认识吗
原创文章,转载请标注出处:https://www.cnblogs.com/V1haoge/p/10755313.html 一.SPI是什么 SPI是相对API而言的. API指的是应用对服务调用方提供 ...

