Skip to content

Instantly share code, notes, and snippets.

@asifbacchus
Created May 27, 2018 12:04
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 asifbacchus/512aac87f24851f7b789c0626e52ee72 to your computer and use it in GitHub Desktop.
Save asifbacchus/512aac87f24851f7b789c0626e52ee72 to your computer and use it in GitHub Desktop.
My default basic nginx.conf that I base most of my setups around. References external configs and site files. The idea is to keep it modularized and easy to read.
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
include /etc/nginx/mime.types;
charset utf-8;
## Include enabled configurations from conf.d/conf-enabled/
include /etc/nginx/conf.d/conf-enabled/*.conf;
# Set default index search options for all sites
index index.php index.html;
## Logging options
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# Turn access logging off by default (for performance)
#access_log /var/log/nginx/access.log main;
access_log off;
# Upstream PHP backend (enable if needed)
#upstream PHP {
# server 127.0.0.1:9000;
#}
## Include enabled server-blocks from sites-enabled/
include /etc/nginx/sites-enabled/*.conf;
}
@asifbacchus
Copy link
Author

asifbacchus commented May 27, 2018

Config settings such as SSL settings are kept separate from this file for readability and ease of updating/reusing. I keep them in /etc/nginx/conf.d and symlinked to /etc/nginx/conf.d/conf-enabled. A working example SSL configuration file is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment