https://github.com/agarzon/nginx-config
Easy to understand and extend Nginx configuration template.
https://github.com/agarzon/nginx-config
boilerplate nginx template
Last synced: 4 months ago
JSON representation
Easy to understand and extend Nginx configuration template.
- Host: GitHub
- URL: https://github.com/agarzon/nginx-config
- Owner: agarzon
- License: mit
- Created: 2016-11-18T19:38:28.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-25T20:46:55.000Z (over 6 years ago)
- Last Synced: 2025-04-06T05:35:37.301Z (9 months ago)
- Topics: boilerplate, nginx, template
- Size: 23.4 KB
- Stars: 19
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nginx Configuration Template
Easy to understand and extend Nginx configuration template
## Features
* GZIP compression support
* PHP handling support
* Cache for static files
* SSL support with http2
* Stronger cypher. SSL rating A+.
* It never will replace any built-in configuration. Upgrading your Nginx will be always safe.
## Installation
Just put the code in your **/etc/nginx**
## Usage
To create a site, add a file with extension **.conf** in **sites-enabled/** folder. Example:
**/etc/nginx/sites-enabled/example.conf**
```nginx
# Force HTTPS
{
server_name mywebsite.com;
return 301 https://$server_name$request_uri;
}
server
{
server_name mywebsite.com;
root /var/www/$server_name/;
listen 443 ssl http2;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
access_log /var/log/nginx/mywebsite.com.log combined buffer=10k flush=1m;
error_log /var/log/nginx/mywebsite.com.error.log error;
set $APPLICATION_ENV production;
include templates/default.conf;
include templates/php.conf;
#include templates/no-php.conf;
#include templates/limits.conf;
include templates/gzip.conf;
include templates/static-cache.conf;
include templates/ssl.conf;
}
```
## Create the Self-Signed SSL Certificate
```
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt
```
And complete the prompt:
```
Country Name (2 letter code) [XX]:CA
State or Province Name (full name):Quebec
Locality Name (eg, city) [Default City]:Montreal
Organization Name (eg, company) [Default Company Ltd]:ACME
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:*.domain.com
Email Address []:
```
## Generate a dhparam key for stronger security
```
openssl dhparam -out /etc/nginx/ssl/dhparams.pem 2048
```