Skip to content

Instantly share code, notes, and snippets.

@holmberd
Last active November 2, 2017 22:01
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 holmberd/cacde906b91b620f4e0291a3111a3e1b to your computer and use it in GitHub Desktop.
Save holmberd/cacde906b91b620f4e0291a3111a3e1b to your computer and use it in GitHub Desktop.
Create SSL certificate for Nginx

  • sudo mkdir /etc/nginx/ssl
  • sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
Country Name (2 letter code) [AU]: __
State or Province Name (full name) [Some-State]: __
Locality Name (eg, city) []: __
Organization Name (eg, company) [Internet Widgits Pty Ltd]: __
Organizational Unit Name (eg, section) []: __
Common Name (e.g. server FQDN or YOUR name) []:your_domain.com
Email Address []:admin@your_domain.com
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