-
-
Save johnnncodes/33eaceb868c4715a2ffacbf3fe15a219 to your computer and use it in GitHub Desktop.
Revisions
-
tompave revised this gist
Apr 16, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ # # Tested with: # Ubuntu 12.04 # nginx 1.4.1 - 1.4.7 # Rails 3.2 - 4.0 # Unicorn, Thin and Puma # -
tompave revised this gist
Apr 16, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -68,6 +68,10 @@ events { # -------------------------------------------------------- http { # disables emitting nginx version in error messages # and in the “Server” response header field server_tokens off; # MIME types include /etc/nginx/mime.types; -
tompave revised this gist
Mar 21, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # # Author: Tommaso Pavese # [email protected] # http://tommaso.pavese.me # # License: http://www.wtfpl.net/ # -
tompave revised this gist
Feb 14, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ # # Tested with: # Ubuntu 12.04 # nginx 1.4.1 - 1.4.5 # Rails 3.2 - 4.0 # Unicorn, Thin and Puma # -
tompave revised this gist
Feb 14, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -69,8 +69,7 @@ events { http { # MIME types include /etc/nginx/mime.types; # fallback MIME type if the client doesn't specify it. default_type application/octet-stream; @@ -96,6 +95,7 @@ http { gzip_types text/plain text/xml text/css text/comma-separated-values text/javascript application/x-javascript application/javascript application/json application/atom+xml; # text/html is included by default -
tompave revised this gist
Feb 7, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -174,7 +174,7 @@ http { # This is weird, but it would still work. upstream rails_app_three { server unix:/tmp/rails_app_three.sock fail_timeout=0; server 192.168.0.7:8080 fail_timeout=0; server 127.0.0.1:3000 weight=3 fail_timeout=0; server backendworker.example.com weight=5 fail_timeout=0; -
tompave revised this gist
Feb 7, 2014 . 1 changed file with 28 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -69,8 +69,11 @@ events { http { # MIME types include mime.types; # the path is relative to this conf file, # in this case /etc/nginx/mime.types # fallback MIME type if the client doesn't specify it. default_type application/octet-stream; # log access_log /var/log/nginx/access.log combined; @@ -83,7 +86,7 @@ http { # use unix sendfile() sendfile on; # gzip compression gzip on; gzip_http_version 1.0; gzip_proxied any; @@ -97,8 +100,11 @@ http { # text/html is included by default # According to the HTTP standard, headers with underscores are perfectly valid. # However, nginx defaults to dropping headers containing underscores, as they # might introduce ambiguities when mapping headers to CGI variables. # # Since this is not a problem with Ruby on Rails, we can safely enable them. underscores_in_headers on; @@ -147,20 +153,33 @@ http { # If more than one destination server is specified, the requests # are distributed using a weighted round-robin balancing method. # # Important: # Unicorn workers can all listen on the same Unix socket (or TCP port) # at the same time. # However, this might not be true for other servers. # A cluster of Thins, for example, will require a Unix socket per process. # Look at the second upstream block for an example. # This works well with Unicorn (yes, even with several workers) upstream rails_app_one { server unix:/tmp/rails_app_one.sock fail_timeout=0; } # This will work with a cluster of 3 Thin servers upstream rails_app_two { server unix:/tmp/rails_app_two.0.sock fail_timeout=0; server unix:/tmp/rails_app_two.1.sock fail_timeout=0; server unix:/tmp/rails_app_two.2.sock fail_timeout=0; } # This is weird, but it would still work. upstream rails_app_three { server unix:/tmp/rails_app_three.sock fail_timeout=0; server 192.168.0.7:8080 fail_timeout=0; server 127.0.0.1:3000 weight=3 fail_timeout=0; server backendworker.example.com weight=5 fail_timeout=0; } # -------------------------------------------------------- # servers -
tompave revised this gist
Feb 3, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -87,6 +87,7 @@ http { gzip on; gzip_http_version 1.0; gzip_proxied any; gzip_vary on; gzip_min_length 500; gzip_disable "MSIE [1-6]\."; gzip_types text/plain text/xml text/css -
tompave revised this gist
Feb 3, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -280,7 +280,7 @@ http { proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://rails_app_two; } # Location block for the assets. # See: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression @@ -304,7 +304,7 @@ http { # Or: # expires 12h; # add_header Cache-Control "public, must-revalidate"; # The 'try_files' directive is NOT inherited from the parent block. try_files $uri =404; -
tompave revised this gist
Feb 2, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -255,8 +255,8 @@ http { # ---------------------------- # This server block features an efficient configuration # to serve the pre-gzipped version of the static assets server { listen 80; -
tompave revised this gist
Feb 2, 2014 . 1 changed file with 47 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,15 +6,13 @@ # # License: http://www.wtfpl.net/ # # # Tested with: # Ubuntu 12.04 # nginx 1.4.1 - 1.4.4 # Rails 3.2 - 4.0 # Unicorn, Thin and Puma # # # Docs: # http://nginx.org/en/docs/ @@ -257,6 +255,8 @@ http { # ---------------------------- # This server block features an efficient configuration for # static assets server { listen 80; @@ -270,20 +270,61 @@ http { root /var/www/winteriscoming/current/public; try_files $uri $uri/index.html $uri.html @rails_app; error_page 500 502 503 504 /500.html; location @rails_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://rails_app_two; } # Location block for the assets. # See: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression # # '^~ /assets/' is a 'prefix string', not a regex. # '^~' will prevent further location searching after this location is matched. # # 'root' is inherited from the parent block. With the default Rails directory # structure it should point to 'app_root/public'. # location ^~ /assets/ { # To serve the pre-gzipped version of the files, if available. # The non-compressed versions MUST be available too, or a 404 will be returned. # The general gzip directives in the 'http' block are still applied. gzip_static on; # Since Rails automatically appends digest fingerprints to asset file names, # we don't need to worry about expiring them. expires max; add_header Cache-Control public; # Or: # expires 12h; # add_header Cache-Control 'public, must-revalidate'; # The 'try_files' directive is NOT inherited from the parent block. try_files $uri =404; # We could also use a less strict directive that falls back to the Rails app # if a requested asset cannot be found. In this case, the cache headers here # configured will be ignored and Rails will set them automatically. # try_files $uri @rails_app; # Normally the Rails app takes care of serving the static file 'public/404.html' # when a 404 occours. Here, however, it will be handled by nginx. error_page 404 /404.html; } } } # A note on $uri and the try_files directive: # # try_files /maintenance.html $uri $uri/index.html $uri.html @rails_app; -
tompave revised this gist
Jan 31, 2014 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -219,7 +219,8 @@ http { # # This is just a named location to be used in try_files. location @rails_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # the client IP proxy_set_header X-Real-IP $remote_addr; # the client IP (again) proxy_set_header X-Forwarded-Proto $scheme; # pass scheme (for HTTPS) proxy_set_header Host $http_host; # the full host, for redirects within Rails proxy_redirect off; # disable nginx redirect-rewrite logic @@ -271,6 +272,7 @@ http { location @rails_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_redirect off; -
tompave revised this gist
Jan 31, 2014 . 1 changed file with 2 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -234,9 +234,8 @@ http { # can also be served by 'try_files $uri', above. Still, this # location is more precise (thus has higher priority) and can # be used to further customize the error response. # # location = /500.html { } } # A redirect from the naked domain to www @@ -279,9 +278,6 @@ http { } error_page 500 502 503 504 /500.html; } } -
tompave revised this gist
Jan 27, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -231,9 +231,9 @@ http { error_page 500 502 503 504 /500.html; # This location block isn't strictly required, as '/500.html' # can also be served by 'try_files $uri', above. Still, this # location is more precise (thus has higher priority) and can # be used to further customize the error response. location = /500.html { root /var/www/example/current/public; } -
tompave revised this gist
Jan 27, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -230,7 +230,7 @@ http { # Customize what html file should be served for different errors. error_page 500 502 503 504 /500.html; # This location block isn't strictly required, as '/500.html' # can also be served by 'try_files $uri', above. This location, # however is more precise, thus has higher priority, and can be # used to further customize the error response. -
tompave revised this gist
Jan 27, 2014 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -226,8 +226,14 @@ http { proxy_pass http://rails_app_one; # http is to be used even for https traffic } # Customize what html file should be served for different errors. error_page 500 502 503 504 /500.html; # This location block isn't strictly required, as '/500.html' will # can also be served by 'try_files $uri', above. This location, # however is more precise, thus has higher priority, and can be # used to further customize the error response. location = /500.html { root /var/www/example/current/public; } -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -112,10 +112,10 @@ http { # - a server{} block # - an upstream{} block # # The convention is to store configuration files in: # /etc/nginx/sites-availbale/ # # and then symlink them into: # /etc/nginx/sites-enabled/ # # with: @@ -145,7 +145,7 @@ http { # # We can also use IP addresses and domain names, and mix them together. # # If more than one destination server is specified, the requests # are distributed using a weighted round-robin balancing method. # upstream rails_app_one { -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -213,7 +213,6 @@ http { # try_files /maintenance.html $uri $uri/index.html $uri.html @rails_app; # The location directory allows very creative configurations. # http://nginx.org/en/docs/http/ngx_http_core_module.html#location @@ -226,6 +225,12 @@ http { proxy_redirect off; # disable nginx redirect-rewrite logic proxy_pass http://rails_app_one; # http is to be used even for https traffic } # Customize what html file to render for error codes error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/example/current/public; } } # A redirect from the naked domain to www @@ -258,7 +263,6 @@ http { root /var/www/winteriscoming/current/public; try_files $uri $uri/index.html $uri.html @rails_app; location @rails_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -267,6 +271,11 @@ http { proxy_redirect off; proxy_pass http://rails_app_two; } error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/winteriscoming/current/public; } } } -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -201,9 +201,11 @@ http { # http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files # # Tries URIs in sequence until one is found. # First we try to serve static files directly from nginx. # The rails application is the last alternative. # # See comment block at the end of the file for detailed examples. # # /maintenance.html can be symlinked into public/ to stop requests # before they reach the rails app (e.g. while updating the DB). -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -149,15 +149,15 @@ http { # are distributed using a weighted round-robin balancing method. # upstream rails_app_one { server unix:/tmp/rails_app_one.sock fail_timeout=0; } upstream rails_app_two { server unix:/tmp/rails_app_two.sock fail_timeout=0; server 192.168.0.7:8080 fail_timeout=0; server 127.0.0.1:3000 weight=3 fail_timeout=0; server backendworker.example.com weight=5 fail_timeout=0; } -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -157,7 +157,7 @@ http { server unix:/tmp/rails_app_two.sock fail_timeout=0; server 192.168.0.7:8080 fail_timeout=0; server 127.0.0.1:3000 weight=3 fail_timeout=0; server backendworker.example.com weight=5 fail_timeout=0; } -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -157,6 +157,7 @@ http { server unix:/tmp/rails_app_two.sock fail_timeout=0; server 192.168.0.7:8080 fail_timeout=0; server 127.0.0.1:3000 weight=3 fail_timeout=0; server one.backend.example.com weight=5 fail_timeout=0; } -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ # # # In order to bind to port 80, the master process must be executed as root: # $ sudo /usr/sbin/nginx -c /etc/nginx/nginx.conf # # How to execute the worker processes -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,8 @@ # [email protected] # www.wonderingmachine.com # # License: http://www.wtfpl.net/ # # Tested with: # Ubuntu 12.04 # nginx 1.4.1 - 1.4.4 -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,8 @@ # # Tested with: # Ubuntu 12.04 # nginx 1.4.1 - 1.4.4 # Rails 3.2 - 4.0 # # Tested in production with Unicorn and Thin. # Also works with Puma (tested in dev). -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,7 @@ # www.wonderingmachine.com # # Tested with: # Ubuntu 12.04 # nginx v 1.4.1 - 1.4.4 # Rails 3.2 - 4.0 # -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 8 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,17 @@ # A commented nginx configuration file for Ruby on Rails # # Author: Tommaso Pavese # [email protected] # www.wonderingmachine.com # # Tested with: # nginx v 1.4.1 - 1.4.4 # Rails 3.2 - 4.0 # # Tested in production with Unicorn and Thin. # Also works with Puma (tested in dev). # # # # Docs: # http://nginx.org/en/docs/ -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,7 +41,7 @@ worker_processes 1; # "open files" is intended as UNIX open file descriptors. # This overrides the limit set by the OS for the user the workers run as. # Run `ulimit -a` in a shell to see the current limit. worker_rlimit_nofile 2048; error_log /var/log/nginx/error.log warn; -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -108,7 +108,7 @@ http { # /etc/nginx/sites-availbale/ # # and then symlink them into: # /etc/nginx/sites-enabled/ # # with: # $ ln -s /etc/nginx/sites-availbale/example.com.conf /etc/nginx/sites-enabled/example.com.conf -
tompave revised this gist
Jan 24, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -219,12 +219,12 @@ http { # A redirect from the naked domain to www # # This listens to port 80, thus it can't handle HTTPS traffic. # (therefore, using $scheme instead of http is a bit useless) # # If the certificate is also compatible with the naked domain, # then this server block can be improved by replicating here # the SSL configuration of the main server. server { listen 80; server_name example.com;
NewerOlder