在azure中将HTTP重定向到HTTPS(带负载均衡器)

编程入门 行业动态 更新时间:2024-10-28 10:31:19
本文介绍了在azure中将HTTP重定向到HTTPS(带负载均衡器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们在Azure中有两个负载均衡的Web服务器。 我们刚刚在这些azure网站上安装了SSL,将其转换为HTTPS。 现在我们希望任何以HTTP形式进入的请求都应该更改/重定向到HTTPS连接。 所以,我测试我在我的本地机器上创建了一个已发布的网站,然后添加了自签名的 SSL证书以获得一个安全的网站。然后我使用URL重写将我的HTTP站点指向HTTPS。 我在Web.config中使用它。 这对我来说很完美当地出版的网站。 但这在Azure服务器上失败并且给我一个内部服务器错误。 有什么想法吗? 我在Web.config中使用以下内容进行URL重写

We have 2 Web servers in Azure that are Load balanced. We just installed SSL in our these azure websites to convert it to HTTPS. Now we want that any request coming in as HTTP should be changed/redirected to HTTPS connection. So, I for testing I created a published website on my local machine, then added self signed SSL certificate to get a secure site. Then I used URL rewrite to direct my HTTP site to HTTPS. I used this in Web.config. This works perfectly on my local published site. But this fails on the Azure server and gives me an Internal Server Error. Any ideas? I used the following in Web.config for the URL rewrite

<rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="Off" /> <add input="{REQUEST_METHOD}" pattern="^get$|^head$" /> </conditions> <action type="Redirect" url="{HTTP_HOST}{REQUEST_URI}" redirectType="SeeOther" /> </rule> </rules> </rewrite>

我有什么试过: 在Web.Config中尝试重写URL。 它在Azure服务器上不起作用。

What I have tried: Tried URL Rewrite in Web.Config . It did not work on Azure Server.

推荐答案

| ^ head

/ > < / conditions > < action type = 重定向 url = https:// {HTTP_HOST} {REQUEST_URI} redirectType = SeeOther / > < / rule > < / rules > < / rewrite > " /> </conditions> <action type="Redirect" url="{HTTP_HOST}{REQUEST_URI}" redirectType="SeeOther" /> </rule> </rules> </rewrite>

我的尝试: 在Web.Config中尝试重写URL。 它在Azure服务器上不起作用。

What I have tried: Tried URL Rewrite in Web.Config . It did not work on Azure Server.

我弄清楚了。 我在服务器上的IIS上缺少URL重写模块。安装完成了诀窍 www.iis/downloads/microsoft/url-rewrite 现在,IIS服务器可以将URL请求从HTTP重定向到HTTPS I figured it out. I was missing the URL rewrite module on IIS on the server. Installing that did the trick www.iis/downloads/microsoft/url-rewrite Now the IIS server can redirect the url requests from HTTP to HTTPS

更多推荐

在azure中将HTTP重定向到HTTPS(带负载均衡器)

本文发布于:2023-11-23 23:41:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623201.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:均衡器   负载   中将   重定向   azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!