简体   繁体   中英

How to send request to backend SSL url that converts from HTTP:7000 to HTTPS:7001 after verification running on weblogic using Angular front end app

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

WEBLOGIC SSL CONFIGURATION

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

  1. 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

This should work:

@Injectable()
export class httpsInterceptor implements HttpInterceptor {
    intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {

    console.log(req.url);

    const secureReq = req.clone({
      url: req.url.replace('http://', 'https://')
    });

    return next.handle(secureReq);
  }
}

you must create an interceptor and import it in the module inside provider, providers: [ { provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true } ]

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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