Ideally, your Rails app just has
config.force_ssl = true configured for its
production environment. However, if you have TLS- and non-TLS contexts in
your app, things become tricky to test on your local development machine.
For Dev/Prod Parity, I want to have the same SSL setup locally as on staging/production. Documentation for setting up a local Nginx instance is readily available, but it’s verbose and involves too many manual steps.
I’ve written a shell script to automate the happy path of the Nginx setup,
namely installing Nginx, creating a self-signed SSL-certificate, writing the
reverse-proxy config directives and optionally starting the Nginx webserver
right away. The latter requires
sudo superpowers since binding to the SSL
default port 443 requires root privileges. Furthermore, it makes a few
You can download the script from Absolventa’s Github repo.
Run it on your machine with
bash nginx-ssl-setup.sh and follow the instructions on your terminal.
If you stray from the Happy Path™, feel free to send a PR our way!