Skip to content

Instantly share code, notes, and snippets.

@seyhunak
Last active December 31, 2015 05:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save seyhunak/7943308 to your computer and use it in GitHub Desktop.
Save seyhunak/7943308 to your computer and use it in GitHub Desktop.
Varnish - Nginx - Unicorn Setup
upstream unicorn {
server unix:/tmp/unicorn.app.sock fail_timeout=0;
}
# HTTP server
#
server {
listen localhost:8080;
server_name app.me;
root /home/ubuntu/www/app/public;
access_log /home/ubuntu/www/app/log/access.log;
error_log /home/ubuntu/www/app/log/error.log;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
proxy_connect_timeout 300;
proxy_read_timeout 300;
}
gzip on;
gzip_http_version 1.0;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_min_length 0;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_proxied expired no-cache no-store private auth;
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
# HTTPS server
#
server {
listen 443;
server_name app.me;
root /home/ubuntu/www/app/public;
access_log /home/ubuntu/www/app/log/access.log;
error_log /home/ubuntu/www/app/log/error.log;
ssl on;
ssl_certificate /home/ubuntu/www/app.crt;
ssl_certificate_key /home/ubuntu/www/app.key;
ssl_ciphers ALL:-ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;
ssl_session_cache shared:SSL:10m;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
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 https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
proxy_connect_timeout 300;
proxy_read_timeout 300;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
server_tokens off;
server {
listen localhost:8080;
location / {
proxy_pass http://<<<< ELB DNS adresi >>>>;
proxy_set_header Host $http_host;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment