Skip to content

Instantly share code, notes, and snippets.

@astrauka
Created May 20, 2015 12:47
Show Gist options
  • Save astrauka/a1fa5d8d1622a2bcae5e to your computer and use it in GitHub Desktop.
Save astrauka/a1fa5d8d1622a2bcae5e to your computer and use it in GitHub Desktop.
nginx
# assumming path to nginx is /etc/nginx/
sudo su
cd /etx/nginx
mkdir certs_localhost
cd certs_localhost
# generate self signed certificate, the identifier for it should be localhost
openssl req -x509 -newkey rsa:2048 -keyout development.key -out development.crt -days 5000 -nodes
cd ..
# ensure that your /etc/nginx/nginx.conf has the following line in http section
include /etc/nginx/sites-enabled/*;
vim sites-enabled/rails_dev
server {
listen 127.0.0.1:80 default;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/certs_localhost/development.crt;
ssl_certificate_key /etc/nginx/certs_localhost/development.key;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
# test nginx configuration
nginx -t
# restart nginx
service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment