enjalot / blockbuilder

Create, fork and edit d3.js code snippets for use with bl.ocks.org right in the browser, no terminal required.
Other
323 stars 59 forks source link

redirect http to https #225

Closed micahstubbs closed 5 years ago

micahstubbs commented 5 years ago

redirect http to https

upgrade normal sesions to secure sessions when possible

micahstubbs commented 5 years ago

will have a go at this one

micahstubbs commented 5 years ago

strategy:

once all is well on the blockbuilder-frontend-2 test server

micahstubbs commented 5 years ago

alright, got my test server working, serving blockbuilder with nginx 🎉

you can check it out at http://blockbuilder.micah.fyi

(and watch the browser upgrade the connection from http to https)

micahstubbs commented 5 years ago

will try out this test server for a bit before switching over the main server.

@enjalot want to take a look at http://blockbuilder.micah.fyi, see switching to nginx breaks anything?

enjalot commented 5 years ago

looks like its in good working order to me. nice job getting a test server running!

micahstubbs commented 5 years ago

to remove IPTABLES rules:

sudo iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8889
sudo iptables -t nat -D PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443

following this answer: https://stackoverflow.com/questions/10197405/how-can-i-remove-specific-rules-from-iptables

(we want to remove the IP Tables rules since we will use nginx going forward, since nginx makes it easy to redirect http to https)

micahstubbs commented 5 years ago

ok, redirecting http to https

sudo certbot --nginx
#
# ...
#
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: blockbuilder.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
tls-sni-01 challenge for blockbuilder.org
Waiting for verification...
Cleaning up challenges
Could not open file: /etc/nginx/sites-enabled/default
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/blockbuilder.org
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/blockbuilder.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Your existing certificate has been successfully renewed, and the new certificate
has been installed.
The new certificate covers the following domains: https://blockbuilder.org
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=blockbuilder.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/blockbuilder.org/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/blockbuilder.org/privkey.pem
   Your cert will expire on 2019-03-03. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le
➜  nginx 
micahstubbs commented 5 years ago

ok, it works 🎉