![](/img/trans.png)
[英]Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR while using news api in react js
[英]Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR - JavaScript to Spring REST API
我购买了一个便宜的 VPS,它是一个 Debian 操作系统,然后我安装了我的 Spring 启动应用程序,它可以侦听简单的 POST 请求。
我的主要网站是 HTTPS 网站,当我尝试通过 JS 与我的廉价 VPS 服务器通信时出现错误
Failed to load resource: net::ERR_SSL_PROTOCOL_ERROR
我认为这是因为我的 VPS IP 未通过 SSL 认证,它是 tomcat 服务器; 我是否需要调整我的 Tomcat 设置才能解决此问题? 我不确定 go 从这里到哪里。 任何帮助表示赞赏。
TL;博士-
我要做的就是执行这行代码,到我在另一个服务器地址上托管的 REST API
$.ajax({
type: "POST",
url: "//223.165.6.213:8080/contact-us",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
success: function (response) {
console.log(response);
}
});
它适用于 Localhost 或当我通过 http://{url} 连接到我的网站时,但在 HTTPS(https://{url}) 网站上时无效。
如果您需要更多信息,请告诉我。 感谢阅读,希望这足够清楚。
url: "//223.165.6.213:8080/contact-us",
//
表示与包含站点使用相同的协议。
它有效......当我通过 http://{url} 连接到我的网站时,
在这种情况下, URL 被解释为http://223.165.6.213:8080/contact-us
,它工作正常
...但不是在 HTTPS(https://{url}) 网站上时。
In this case the URL is interpreted as https://223.165.6.213:8080/contact-us
, ie HTTPS instead of plain HTTP. 虽然理论上服务器可能在同一端口(在本例中为 8080)上同时支持普通的 HTTP 和 HTTPS,但这种情况并不常见。 Trying to access this domain and port with HTTPS shows that the server is not setup for HTTPS, but it instead returns a plain HTTP error - specifically HTTP status code 400 for Bad request:
$ openssl s_client -connect 223.165.6.213:8080 -debug
...
0000 - 48 54 54 50 2f HTTP/
140588768077632:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:332:
...
0000 - 31 2e 31 20 34 30 30 20-0d 0a 43 6f 6e 74 65 6e 1.1 400 ..Conten
...
一般来说,更常见的做法是首先不将端口 8080 上的服务器公开,而是将主服务器用作某些路径的反向代理,从而让主服务器也终止 TLS。 如何配置取决于您使用的服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.