Created
April 10, 2018 20:01
-
-
Save fedescarpa/c391202762d04cf5d1028c455dd5f476 to your computer and use it in GitHub Desktop.
Basic Nginx config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www-data; | |
worker_processes auto; | |
pid /run/nginx.pid; | |
events { | |
worker_connections 768; | |
multi_accept on; | |
} | |
http { | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE | |
ssl_prefer_server_ciphers on; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_vary on; | |
gzip_proxied any; | |
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; | |
proxy_cache_path /tmp/nginx levels=1:2 inactive=60m; | |
proxy_cache_key "$scheme$request_method$host$request_uri"; | |
include /etc/nginx/conf.d/*.conf; | |
upstream <UPSTREAM_NAME> { | |
server <IP1>:<PORT>; | |
server <IP2>:<PORT>; | |
server <IPN>:<PORT>; | |
} | |
server { | |
listen 80; | |
server_name example.com; | |
location /.well-known/acme-challenge/ { | |
root /path/to/https/certs; | |
} | |
location / { | |
# To redirect all http request to https | |
return 301 https://$host$request_uri; | |
} | |
} | |
server { | |
listen 443 ssl; | |
server_name example.com; | |
include includes/ssl-settings.conf; | |
include includes/assets-settings.conf; | |
include includes/static-settings.conf; | |
include includes/home-settings.conf; | |
location / { | |
proxy_pass http://<UPSTREAM_NAME>; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_set_header X-Forwarded-Ssl on; # Optional | |
proxy_set_header X-Forwarded-Port $server_port; | |
proxy_set_header X-Forwarded-Host $host; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment