0

I am trying to enable SSL in my Angular application. What I am thinking about if a user come to my site, it will work keep serving on http until he tries to enter into sensitive areasd of the site. but like user click on login link it will change the http to https and then keep serving them on https if he successfully logged. How it could be possible?

Ammar Khan
  • 2,565
  • 6
  • 35
  • 60
  • Maybe it is a problem with your backend. Have you tried to redirect user from http to https ? – themyth92 Dec 04 '14 at 09:10
  • Problem with backend? I even did not enable ssl yet, I need suggestion how could I make things work like abov? – Ammar Khan Dec 04 '14 at 09:16
  • Oh sorry for misunderstanding your question. I am not familiar with .NET so I can not give you an answer in setting up your backend. But I dont think AngularJS has any thing relating to http or https (correct if I am wrong) – themyth92 Dec 04 '14 at 09:30
  • I am not quite sure, thinking about how would angular routing pick up the https on login page if user come first time on a site he will serve with http instead of https. – Ammar Khan Dec 04 '14 at 09:42

1 Answers1

0

If your login is handled by a Angular component, and you want to test it in your Angular development server, then add ssl in Angular.

I use my existing Apache2 certificate (and key-file) in the Angular development server.

Start Angular in bash:

ng serve --ssl 1 --ssl-cert /etc/ssl/private/server.key.pem --ssl-key /etc/ssl/private/server.key.pem --host myserver

The development server can be accessed by browsing to: https://myserver:4200/

In a production environment I forward all http-request to ssl.

In my projects I access a backend with httpclient with ssl as well.

If you want to use HTTP and SSL for the same webserver, you can check this:

Same server, both SSL and non-SSL

Rob Lassche
  • 841
  • 10
  • 16