How to Get Rid of that Pesky “Not Secure” Tag on Your Web Application

Then, add these two files to your default.conf’s port 443 configuration, as such:server{ listen 80; return 301 https://$host$request_uri;}server { listen 443; server_name _; ssl on; ssl_certificate /absolute/path/to/your/certificate.crt; ssl_certificate_key /absolute/path/to/your/key.key;}Additionally, add some SSL config to allow your certificates to play nicely with Nginx:server{ listen 80; return 301 https://$host$request_uri;}server { listen 443; server_name _; ssl on; ssl_certificate /absolute/path/to/your/certificate.crt; ssl_certificate_key /absolute/path/to/your/key.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; #charset koi8-r; access_log /var/log/nginx/access.log main;}Now, direct the port config to the static files you need Nginx to serve:server{ listen 80; return 301 https://$host$request_uri;}server { listen 443; server_name _; ssl on; ssl_certificate /absolute/path/to/your/certificate.crt; ssl_certificate_key /absolute/path/to/your/key.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; #charset koi8-r; access_log /var/log/nginx/access.log main; root /path/to/your/build/folder; index index.html index.htm;}Now, we have to set up a reverse proxy to redirect HTTPS back to HTTP:server{ listen 80; return 301 https://$host$request_uri;}server { listen 443; server_name _; ssl on; ssl_certificate /absolute/path/to/your/certificate.crt; ssl_certificate_key /absolute/path/to/your/key.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; #charset koi8-r; access_log /var/log/nginx/access.log main; root /path/to/your/build/folder; index index.html index.htm; location / { } location /gogetter/api { proxy_pass http://server.instance.ip.address:port; proxy_set_header HOST $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }}Lastly, we need to add an error page, which is already built and stored in an Nginx folder..Simply paste in this code:server{ listen 80; return 301 https://$host$request_uri;}server { listen 443; server_name _; ssl on; ssl_certificate /absolute/path/to/your/certificate.crt; ssl_certificate_key /absolute/path/to/your/key.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; #charset koi8-r; access_log /var/log/nginx/access.log main; root /path/to/your/build/folder; index index.html index.htm; location / { } location /gogetter/api { proxy_pass http://server.instance.ip.address:port; proxy_set_header HOST $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}From here, you should be able to hit your server after changing any and all REST requests to https..The reverse proxy will automatically redirect the requests to HTTP so your server will not have to be updated at all..Happy coding!. More details

Leave a Reply