- Install nginx
brew install nginx
- Cd into the nginx directory
/usr/local/etc/nginx
- Create a
ssl
directory, change and generate a dummy ssl cert:
mkdir ssl
cd ssl
penssl req -new -newkey rsa:2048 -sha1 -days 365 -nodes -x509 -keyout server.key -out server.crt
(just accept the default empty settings)
- Go back to the nginx directory
cd ..
- Create or edit nginx.conf with the following settings:
events {
worker_connections 1024;
}
http {
server {
listen 443 ssl;
server_name local.dev;
ssl on;
ssl_certificate /usr/local/etc/nginx/ssl/server.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/server.key;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-SSL 1;
}
}
}
- Add ssl config in
/config/environments/development.rb
and production.rb
Rails.application.configure do
config.force_ssl = true
end
- Go back to your app directory and run the rails server:
rails s
- Visit https://localhost:3000 and accept any certificate warnings
- ???????
- PROFIT!!
BAM! You're done!