-
Notifications
You must be signed in to change notification settings - Fork 3
Nginx Configuration
Ahmed Hisham Ismail edited this page Feb 24, 2016
·
3 revisions
Sample nginx config. Don't forget to replace content of angle brackets
user nginx;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
types_hash_max_size 2048;
client_max_body_size 10m;
client_body_buffer_size 128k;
reset_timedout_connection on;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
gzip on;
gzip_min_length 1024;
gzip_comp_level 9;
gzip_proxied any;
gzip_types text/html text/css application/x-javascript text/xml application/json application/xml application/xml+rss text/javascript;
gzip_vary on;
upstream api {
server 127.0.0.1:<port1>;
server 127.0.0.1:<port2>;
server 127.0.0.1:<port3>;
}
upstream hooks {
server 127.0.0.1:<port>;
}
server {
listen 80;
server_name evaluator.in www.evaluator.in;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name evaluator.in www.evaluator.in;
ssl_certificate /etc/letsencrypt/live/evaluator.in/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/evaluator.in/privkey.pem;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:20m;
ssl_session_timeout 10m;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK';
ssl_prefer_server_ciphers on;
reset_timedout_connection on;
location /api/ {
proxy_pass http://api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /hooks {
proxy_pass http://hooks/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
location /faye {
proxy_pass http://api/faye;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_redirect off;
}
location / {
root <server/root>;
index index.html;
gzip_static on;
}
}
}