Created
January 1, 2016 07:51
-
-
Save antoniputra/88fc9059abbb247c9095 to your computer and use it in GitHub Desktop.
SSL in ubuntu localhost
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
# 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