Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tontonsb/NGINX-snippets
Nginx snippets and examples
https://github.com/tontonsb/NGINX-snippets
example-project hacktoberfest nginx nginx-snippets
Last synced: 7 days ago
JSON representation
Nginx snippets and examples
- Host: GitHub
- URL: https://github.com/tontonsb/NGINX-snippets
- Owner: tontonsb
- License: mit
- Created: 2020-01-20T00:04:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-16T01:35:37.000Z (4 months ago)
- Last Synced: 2024-08-02T15:07:02.654Z (3 months ago)
- Topics: example-project, hacktoberfest, nginx, nginx-snippets
- Language: DIGITAL Command Language
- Homepage:
- Size: 38.1 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# NGINX snippets
Some building blocks and structure for Nginx config to change the Nginx server
file from this```
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;access_log /var/log/nginx/redirected.access;
error_log /var/log/nginx/redirected.error;server_name
example.com
sub.example.com
sub3.example.com;return 301 https://www.$host$request_uri;
}
```to this
```
server {
include snippets/listen/all.conf;
include snippets/ssl.conf;
include snippets/log-redirect.conf;server_name
example.com
sub.example.com
sub3.example.com;return 301 https://www.$host$request_uri;
}
```It gets very easy to comprehend what's going on in the config once you get
used to ignore `include snippets/` and just read what it says. Especially
useful when setting up many vhosts.The snippets are in the snippets dir. Usage examples in sites-available dir.
## Notes, conventions, tips
All junk that you don't use like `koi-win` or `uwsgi_params` can be removed.
I usually only have this in the nginx root:
```
$ ls /etc/nginx
conf.d/ modules@ modules-enabled/ nginx.conf sites-available/ sites-enabled/ snippets/
```Note that some of the *snippets* like `mime.types`, `proxy_params` and the
fastcgi conf are not there either. This config template places them within
appropriate directories.Anything general like *ssl* or *gzip* config should go into `conf.d`. Anything
includable should go into snippets.