Mixed Content: The page at 'https://service.tec-development.com/webappr/' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'http://service.tec-development.com/webappr/Signin/scan_code_sign'. This endpoint should be made available over a secure connection.
时间: 2024-01-03 21:04:19 浏览: 40
这个错误通常是因为你的网站使用了 HTTPS 加密协议,但是在网站中包含了一个表单,表单的提交地址却是 HTTP 协议。
在 HTTPS 页面中加载 HTTP 资源,或者将 HTTPS 页面中的表单提交到 HTTP 地址,会导致浏览器认为这是一种混合内容,会阻止加载或提交,以保证用户的安全。
要解决这个问题,需要将表单的提交地址修改为 HTTPS 地址,或者将整个网站的 HTTP 部分都升级为 HTTPS。
具体做法:
1. 将表单的提交地址修改为 HTTPS。在表单的 HTML 代码中,将 action 属性中的 `http` 修改为 `https`,例如:
```
<form action="https://service.tec-development.com/webappr/Signin/scan_code_sign" method="post">
...
</form>
```
2. 将整个网站升级为 HTTPS。可以通过在服务器上安装 SSL 证书,并将网站的所有链接都修改为 HTTPS 链接来实现。你可以参考一些网站部署 HTTPS 的教程进行操作。
相关问题
niginx报错Mixed Content: The page at 'https://service.tec-development.com/webappr/' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'http://service.tec-development.com/webappr/Signin/scan_code_sign'. This endpoint should be made available over a secure connection.
这个错误通常是因为 nginx 代理服务器将 HTTPS 请求转发到了 HTTP 服务器,而在该 HTTP 服务器中包含了一个表单,该表单的提交地址为 HTTP 地址,因此出现了混合内容错误。
要解决这个问题,可以有两种方法:
1. 将 HTTP 服务器升级为 HTTPS 服务器。这样就可以避免出现混合内容错误。
2. 将 nginx 代理服务器配置为在转发请求时将 HTTP 链接修改为 HTTPS 链接。可以使用 nginx 的 sub_filter 模块来实现这个功能。具体的配置可以参考下面的示例:
```
location / {
proxy_pass http://service.tec-development.com;
sub_filter 'http://service.tec-development.com' 'https://service.tec-development.com';
sub_filter_once off;
proxy_set_header Accept-Encoding "";
proxy_set_header Host $host;
}
```
这个配置会将请求中的所有 `http://` 链接替换成 `https://` 链接,并且在转发时禁用 Accept-Encoding 头部,防止出现压缩问题。此时,表单提交的地址也会被修改为 HTTPS 地址,从而解决混合内容错误。
错误:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an insecure.......
这个错误是由于网页中同时存在HTTP和HTTPS两种不同的资源,浏览器为了保证安全性会阻止加载不安全的HTTP资源。解决这个问题的方法有两种:
1. 将所有的HTTP资源都替换成HTTPS资源,这样就不会存在Mixed Content的问题了。
2. 在网页的头部添加Content-Security-Policy,设置upgrade-insecure-requests,这样浏览器会自动将HTTP请求转换成HTTPS请求,从而避免Mixed Content的问题。
以下是两种解决方法的代码示例:
1. 将所有HTTP资源替换成HTTPS资源
```html
<!-- 替换前 -->
<img src="http://example.com/image.jpg">
<!-- 替换后 -->
<img src="https://example.com/image.jpg">
```
2. 在网页头部添加Content-Security-Policy
```html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>My Secure Page</title>
</head>
<body>
<!-- Your secure content here -->
</body>
</html>
```