Skip to content

Instantly share code, notes, and snippets.

@darrenmothersele
Created December 2, 2018 11:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darrenmothersele/3ea329307f56730920b5f19b1f53ff91 to your computer and use it in GitHub Desktop.
Save darrenmothersele/3ea329307f56730920b5f19b1f53ff91 to your computer and use it in GitHub Desktop.
Serving Angular CLI project over HTTPS / generate SSL cert / configure Angular CLI / optionally use NGINX via Docker
#!/bin/bash
docker run --name fc \
-v $PWD/ssl:/etc/nginx/certs \
-v $PWD/ssl/nginx-default.conf:/etc/nginx/conf.d/default.conf:ro \
-v $PWD/dist/___PROJECT_NAME___:/usr/share/nginx/html:ro -p 8080:443 -d nginx
#!/bin/bash
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout server.key \
-new \
-out server.crt \
-config ./openssl-custom.cnf \
-sha256 \
-days 365
#!/bin/bash
sudo cp server.crt /etc/ca-certificates/trust-source/anchors/
sudo update-ca-trust
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
[req]
default_bits = 2048
prompt = no
default_md = sha256
x509_extensions = v3_req
distinguished_name = dn
[dn]
C = US
ST = KS
L = Olathe
O = IT
OU = IT Department
emailAddress = webmaster@example.com
CN = localhost
[v3_req]
subjectAltName = @alt_names
[alt_names]
DNS.1 = *.localhost
DNS.2 = localhost
"scripts": {
"start:dev": "ng serve --ssl true --ssl-cert ssl/server.crt --ssl-key ssl/server.key",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment