Skip to content

omnipede/self-signed-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

self-signed-nginx

Nginx self-signed SSL autoconfiguration script.

Requirements

  • ubuntu >= 18.0.4

How to use

First, edit start.conf configuration file properly.

Then execute installation script inside this project folder.

$ pwd
/path/to/this/repo

$ sudo sh start.sh

After installation, write following nginx *.conf file on /etc/nginx/conf.d folder. You should change some parts of the file.

  1. Change example.com to your server domain name.
  2. (Optional) Change example.access.log to preferrable log file name.
  3. Change path of static files /srv/www/dist/ to path you want.
server {
    listen 443 ssl;
    
    # Change me
    server_name example.com;
    
    # Change me
    access_log /var/log/nginx/example.access.log main;
    
    # This is for SPA routing feature of web front framework (e.g. React.js, Vue.js)
    location @rewrites {
    	rewrite ^(.+)$ /index.html last;
    }

    # Serve static files
    location / {
    
        # Change me
        root /srv/www/dist/;
        index index.html;
        try_files $uri $uri/ @rewrites;
    }
    
    gzip on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_min_length 1000;
    gzip_disable    "MSIE [1-6]\."
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
}

As you know, the above file is a normal nginx server definition file.
You can modify the file as you want based on official nginx syntax.

After nginx configuration, start nginx processes by

$ sudo nginx -t
$ sudo service nginx start

For development & testing

I've made Dockerfile for development of this shell script. You can use the dockerfile for multiple times of nginx installation while developing this script.

TODO

  • Add self-signed ssl test script.

About

Nginx self-signed SSL autoconfiguration script.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published