Created
November 7, 2012 12:49
-
-
Save vessi/4031430 to your computer and use it in GitHub Desktop.
nginx configuration for load-balanced proxy-pass with unix-sockets
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
# available in /etc/nginx/nginx.conf | |
user www-data; | |
worker_processes 4; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 768; | |
} | |
http { | |
sendfile on; | |
client_max_body_size 100M; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
## | |
# Logging Settings | |
## | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
## | |
# Gzip Settings | |
## | |
gzip on; | |
gzip_disable "msie6"; | |
include /etc/nginx/proxy_params; | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
} |
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
# available in /etc/nginx/sites-enabled/rails_app.conf | |
server { | |
listen 80; | |
server_name rails.app.tld; | |
access_log /var/log/nginx/rails.app.tld.access.log; | |
error_log /var/log/nginx/rails.app.tld.error.log; | |
location /images { | |
root /var/www/rails_app2/shared/public; | |
} | |
location / { | |
proxy_pass http://rails_app; | |
} | |
} |
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
# placed in /etc/nginx/conf.d/upstream.conf | |
upstream rails_app { | |
server unix:/var/www/rails_app/shared/sockets/rails_app.socket weight=10 max_fails=3 fail_timeout=30s; | |
server unix:/var/www/rails_app2/shared/sockets/rails_app.socket weight=10 max_fails=3 fail_timeout=30s; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment