Skip to content

Instantly share code, notes, and snippets.

@antoniputra
Created January 1, 2016 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniputra/88fc9059abbb247c9095 to your computer and use it in GitHub Desktop.
Save antoniputra/88fc9059abbb247c9095 to your computer and use it in GitHub Desktop.
SSL in ubuntu localhost
# create this under the Nginx configuration directory:
sudo mkdir /etc/nginx/ssl
# Now that we have a location to place our files,
# we can create the SSL key and certificate files in one motion by typing:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
# The only thing we would need to do to get SSL working on this same server block,
# while still allowing regular HTTP connections, is add a these lines:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
root /usr/share/nginx/html;
index index.html index.htm;
server_name your_domain.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
location / {
try_files $uri $uri/ =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment