如何使用 Angular 前端应用程序在 weblogic 上运行验证后将请求发送到后端 SSL url,该 URL 从 HTTP:7000 转换为 HTTPS:7001
我有一个在 weblogic 服务器上运行的后端应用程序。它在 http://localhost:7000 上运行。必须使用 http://localhost:7000 调用此应用程序,然后在验证后检查应用程序架构是否位于 https 上。如果不是,那么它会要求您重定向到 https://localhost:7001。 HTTPS 配置在 weblogic 服务器上启用
到目前为止,所有内容都在同一域上运行,这意味着应用程序是成熟的,具有 Java 后端和 Angular JS 嵌入式前端。所以一切都在 weblogic 服务器上运行。 现在我们正处于从 Angular JS 迁移到 Angular 的过程中。现在 Angular 正在 http://localhost:4200 上运行。所以我创建了一个HTTP调用代理
{ “/api”:{ "target": " http://127.0.01:7000", “安全”:假, "logLevel": "调试", “更改来源”:true } 并
像这样启动服务器: ngserve --proxy-config proxy.conf.json -o
服务器在 4200 上启动并在 http:// 上创建代理127.0.01:7000/api
我还为HTTPS调用创建了ssl代理 { “/api”:{ “目标”:“https://127.0.01:7001”, “安全”:假, "logLevel": "调试", “更改来源”:true } 还在不同
的端口上启动了服务器 ngserve --proxy-config proxy.ssl.conf.json --端口 4400
服务器在 4400 上启动并在 上创建代理https://127.0.01:7001/api
现在我第一次调用后端 url http://127.0.01:7000/api/permission 它通过 http://localhost:4200/api/permission 进行调用
它会通过过滤器并进行一些处理,然后检查调用是否通过 http 或 https,如果不是,则要求重定向到 https://localhost:7001/api/带有一些状态代码的许可。
因此,在拦截器内部的角度中,我检查状态,如果状态用于重定向,则将 url 重定向到 https://127.0.01:7001/api/permission 使用 window.location.href=”https://localhost:4400/api/permission” 不要混淆,因为它调用类似 https://localhost:4400 并与后端 url(即 /api/permission)连接。 Angular 的人们必须意识到这一点。 但我在 chrome 开发工具控制台上收到 504 错误网关超时 在我启动了 ng 服务器的 cmd 上,我得到了这个 尝试将请求 /api/permission 从 localhost:4400 代理到 https://127.0.01:7001 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
我非常确定这是一个 SSL 问题,但我只是不知道如何解决这个问题。 我对此做了很多研究。我很沮丧,我花了足够多的时间来寻找解决方案。我基本上无法移动它,直到它从 http 转换为 https,因为其余的 uri 调用必须在 https 上进行。
我找到了一个链接 如何将 HTTPS 请求从 Angular 前端发送到使用自签名证书保护的服务器?
我认为第一个解决方案是有意义的
- 添加自签名运行角度应用程序的服务器上受信任存储的证书。 (但就你而言,你不能这样做,因为你无法访问 gitpages 可信存储。
但我不能肯定地说。 请提供任何帮助。我真的很感激。我现在几乎陷入困境。
干杯
I have a backend application that is running on weblogic server. It is running on http://localhost:7000. This application has to be called with http://localhost:7000 then after verification it checks if the application schema is on https or not. If its not then it asks you to redirect to https://localhost:7001. The HTTPS configuration is enabled on weblogic server
So far everything running on same domain meaning the application is full fledge with java backend and angular js embedded frontend. So everything running on weblogic server.
Now we are in the process of migrating from angular js to angular. Now angular is running on http://localhost:4200. So I have created a proxy for HTTP call
{
"/api": {
"target": " http://127.0.01:7000",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
And started server like so:
ng serve --proxy-config proxy.conf.json -o
server started on 4200 and creates proxy on http://127.0.01:7000/api
I have also created ssl proxy for HTTPS call
{
"/api": {
"target": "https://127.0.01:7001",
"secure": false,
"logLevel": "debug",
"changeOrigin": true
}
}
Also started server like so on different port
ng serve --proxy-config proxy.ssl.conf.json –-port 4400
server started on 4400 and creates proxy on https://127.0.01:7001/api
Now I make the first call to backend url http://127.0.01:7000/api/permission
It calls through as http://localhost:4200/api/permission
It goes through filter and does some processing then it checks if call is through http or https if not then asks to redirect to https://localhost:7001/api/permission with some status code.
So in angular inside interceptor I check for the status, if status is for redirect, I redirect the url to
https://127.0.01:7001/api/permission
using
window.location.href=”https://localhost:4400/api/permission”
don’t be confuse because it calls like https://localhost:4400 and concat with backend url which is /api/permission.
Angular folks must be aware of that.
But I get a 504 error gateway timeout on chrome dev tools console
On cmd where I have started the ng server I get this
Error occurred while trying to proxy request /api/permission from localhost:4400 to https://127.0.01:7001 (ECONNRESET) (https ://nodejs.org/api/errors.html#errors_common_system_errors)
I am dead sure it’s a SSL issue but I just don’t know how to fix this.
I have done a lot research on this. I am frustrated, I have spent more than enough time to find a solution for this. I cant basically move pass this till its converted from http to https because rest of the uri calls must be made on https.
I found a link
How to send an HTTPS request from an Angular front-end to a server secured with a self signed certificate?
I think solution number one made sense
- Add the self-signed certificate to the trusted store on the server where the angular app runs. (But in your case u cant do this because u got no access to the gitpages trusted store.
But I cant say for sure.
Any help please. I would really appreciate that. I am pretty much stuck at this point.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可行:
您必须创建一个拦截器并将其导入提供程序内的模块中,
提供者:[
{ 提供: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true } ]
This should work:
you must create an interceptor and import it in the module inside provider,
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true } ]
抱歉我回答有点晚了。但我的问题的确切答案是 PKI,它是在 weblogic 上配置的相互身份验证,其完成方式是您需要在 weblogic 上部署角度应用程序以启动相互身份验证。如果有人想要学习以及如何在 weblogic 上配置相互身份验证,他们有几个关于如何在 weblogic 上部署 Angular 应用程序的视频。干杯
Sorry I am a bit late to answer. But the exact answer to my problem was PKI which is mutual authentication configured on weblogic and the way its done is you need to deploy your angular app on weblogic to kick in mutual authentication. There are several videos out their on how to deploy angular app on weblogic if someone looking to learn as well as how to configure mutual authentication on weblogic. Cheers