简体   繁体   English

在AWS中使用Application Load Balancer(ALB)时出现混合内容问题

[英]Mixed content issue in using Application Load Balancer (ALB) in AWS

I have an ASP.Net web application hosted on IIS. 我在IIS上托管了ASP.Net Web应用程序。 The web application (an Umbraco site) is configured to have an HTTP binding in IIS and an SSL certificate is bound to an Application Load Balancer (ALB) in AWS which is used to manage user requests via HTTPS. Web应用程序(Umbraco站点)配置为在IIS中具有HTTP绑定,并且SSL证书绑定到AWS中的应用程序负载均衡器(ALB),该负载均衡器用于通过HTTPS管理用户请求。 This means that when a user requests a resource the ALB redirects any HTTP traffic to HTTPS and then forwards the requests to IIS via the port 80 (internal traffic within the VPC). 这意味着,当用户请求资源时,ALB会将所有HTTP通信重定向到HTTPS,然后通过端口80(VPC内部的通信)将请求转发到IIS。

For most resources this is absolutely fine but there are a handfull of resources (fonts and images) which seem to be requested over HTTP which causes a mixed content warning in the browser. 对于大多数资源来说,这绝对不错,但是似乎有少量资源(字体和图像)似乎是通过HTTP请求的,这会在浏览器中引起混合内容警告。 I have tried HTTP -> HTTPS rewrite rules in IIS and outbound rules to rewrite the response but this does not seem to resolve the issue. 我已经尝试在IIS中使用HTTP-> HTTPS重写规则,并尝试使用出站规则重写响应,但这似乎无法解决问题。

Can anyone help? 有人可以帮忙吗?

The solution to the problem was this to run the the web-app locally as HTTPS rather than HTTP and update the load balancer to forward requests to the web-server on port 443 rather than port 80. 解决该问题的方法是,以HTTPS而不是HTTP的形式在本地运行Web应用程序,并更新负载均衡器以将请求转发到端口443而不是端口80上的Web服务器。

To do so 这样做

  • Create a development SSL certificate on IIS. 在IIS上创建开发SSL证书。 Rather than creating a self-signed certificate I used this project ( https://github.com/FiloSottile/mkcert ) to do so that the certificate was tusted 我使用此项目( https://github.com/FiloSottile/mkcert )来创建证书,而不是创建自签名证书
  • In AWS update the target group that the ALB listener used to forward requests to the IIS server on port 443 rather than port 80. 在AWS中,更新ALB侦听器用来将请求转发到端口443而不是端口80上的IIS服务器的目标组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM