-
-
Save lgs/b78bd1700620dff742e1 to your computer and use it in GitHub Desktop.
nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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