Skip to content

Instantly share code, notes, and snippets.

@croby
Created December 8, 2011 17:39
Show Gist options
  • Save croby/1447754 to your computer and use it in GitHub Desktop.
Save croby/1447754 to your computer and use it in GitHub Desktop.
nginx SSL sample configuration
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
location / {
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
@croby
Copy link
Author

croby commented Dec 8, 2011

Follow this to generate the .crt and the .key

# generate super secret private key
# (not really, this key and the certificate are "throwaway" items)
openssl genrsa -des3 -out ssl.key 1024

# generate the self-signed certificate
openssl req -new -x509 -nodes -sha1 -days 365 -key ssl.key -out ssl.crt

# create decrypted version of key so that nginx can be started without a passphrase
openssl rsa -in ssl.key -out ssl.key.insecure
chmod 600 ssl.key.insecure

source: https://wincent.com/wiki/Generating_self-signed_SSL_certificates_for_use_with_nginx

@croby
Copy link
Author

croby commented Dec 8, 2011

Then just run
sudo nginx -c /full/path/to/ssl_nginx.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment