Larry Jing
Larry Jing

Reputation: 404

How to enable https for a dev environment on Angular app

I have created a website using angular that I am hosting on AWS EC2. I have done some research into how to get my server to be secure with https, and it looks like here are my options:

  1. use angular, add https into angular app
  2. use AWS, use load balancers and use https listener

However, I am new to both AWS and Angular and don't really know where to go from here. My web server is run on Ubuntu, and the 2 tutorials on AWS are for Windows or Linux. Any resources/suggestions?

Upvotes: 0

Views: 761

Answers (2)

Apoorva Chikara
Apoorva Chikara

Reputation: 8773

Angular provides the way to run your website on SSL

ng serve --ssl 

Also, you can add SSL cert path in the angular.json file:

{
   "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
   "projects": {
       "<PROJECT-NAME>": {
           "architect": {
               "serve: {
                   "options": {
                       "sslKey": "<relative path from angular.json>/server.key",
                       "sslCert": "<relative path from angular.json>/server.crt",
                       ...
                   }, ...
               }, ...
           }, ...
       }, ...
   }, ...
}

you can setup load balancer on EC2 instance using this guide:

https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-create-https-ssl-load-balancer.html

Upvotes: 1

anemyte
anemyte

Reputation: 20276

The easiest way to add HTTPS IMO would be installing a web server (like NGINX or Apache2) as a reverse-proxy for your application. The purpose of a web-server in this case would be to accepts requests over HTTPS and forward them with HTTP to your application. Once the application responded, a reverse proxy would pass the response back to client using HTTPS.

If you have NGINX or Apache2 you can use certbot to obtain and renew a certificate from letsencrypt. There are lots of guides how to setup all this on the Internet, just google for nginx letsencrypt angular.

Upvotes: 0

Related Questions