https://github.com/oscarotero/nginx-snippets
Custom snippets for nginx
https://github.com/oscarotero/nginx-snippets
nginx nginx-configuration
Last synced: about 1 month ago
JSON representation
Custom snippets for nginx
- Host: GitHub
- URL: https://github.com/oscarotero/nginx-snippets
- Owner: oscarotero
- License: mit
- Created: 2018-08-07T18:14:35.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-11T13:06:48.000Z (about 6 years ago)
- Last Synced: 2025-03-18T16:04:07.670Z (about 1 month ago)
- Topics: nginx, nginx-configuration
- Size: 12.7 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nginx-snippets
Custom snippets for nginx with http2
## Install
```
cd /etc/nginx/snippets
git clone https://github.com/oscarotero/nginx-snippets.git
```## Snippets
This package contains a set of config files with best practices that you can include in your nginx config.
- `http.conf`: Common http settings to include inside the `http` block.
- `server.conf`: Common http settings to include inside each `server` block.
- `html.conf`: Settings, headers and security stuff to use with html responses.
- `media.conf`: Settings, headers and security stuff to use with media responses (images, videos, audio, fonts, etc).
- `assets.conf`: Settings, headers and security stuff to use with text-based assets like css and javascript.## Usage
```conf
http {
include snippets/nginx-snippets/http.conf;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;include snippets/nginx-snippets/server.conf;
location / {
include snippets/nginx-snippets/html.conf;
}# Media and fonts
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc|ttf|ttc|otf|eot|woff|woff2)$ {
include snippets/nginx-snippets/media.conf;
}# Assets: css, javascript, etc
location ~* \.(?:css|js|webmanifest)$ {
include snippets/nginx-snippets/assets.conf;
}
}
}
```## Other tools
- Configure CSP: [CSP is Awesome](https://www.cspisawesome.com/):
- Configure SSL: [Mozilla SSL Configuration Generator](https://mozilla.github.io/server-side-tls/ssl-config-generator/)
- NGINX Config Generator: [nginxconfig.io](https://nginxconfig.io/)
- NGINX Quick Reference: [trimstray/nginx-quick-reference](https://github.com/trimstray/nginx-quick-reference)## Testing
- [Observatory by Mozilla](https://observatory.mozilla.org/)
- [Webhint](https://webhint.io/scanner/)
- [PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights/)