Last active
December 12, 2015 10:38
-
-
Save albertogg/4760649 to your computer and use it in GitHub Desktop.
nginx configuration file with server block unicorn ready.
This file contains 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 deploy; | |
worker_processes 1; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 768; | |
# multi_accept on; | |
} | |
http { | |
## | |
# Basic Settings | |
## | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 75; | |
types_hash_max_size 2048; | |
# server_tokens off; | |
# server_names_hash_bucket_size 64; | |
# server_name_in_redirect off; | |
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"; | |
# gzip_vary on; | |
# gzip_proxied any; | |
# gzip_comp_level 6; | |
# gzip_buffers 16 8k; | |
# gzip_http_version 1.1; | |
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
## | |
# nginx-naxsi config | |
## | |
# Uncomment it if you installed nginx-naxsi | |
## | |
#include /etc/nginx/naxsi_core.rules; | |
## | |
# Virtual Host Configs | |
## | |
include /etc/nginx/conf.d/*.conf; | |
include /etc/nginx/sites-enabled/*; | |
} | |
#mail { | |
# # See sample authentication script at: | |
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript | |
# | |
# # auth_http localhost/auth.php; | |
# # pop3_capabilities "TOP" "USER"; | |
# # imap_capabilities "IMAP4rev1" "UIDPLUS"; | |
# | |
# server { | |
# listen localhost:110; | |
# protocol pop3; | |
# proxy on; | |
# } | |
# | |
# server { | |
# listen localhost:143; | |
# protocol imap; | |
# proxy on; | |
# } | |
#} |
This file contains 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
upstream unicorn { | |
server unix:/tmp/unicorn.sock fail_timeout=0; | |
} | |
server { | |
listen 80; ## listen for ipv4; this line is default and implied | |
#listen [::]:80 default ipv6only=on; ## listen for ipv6 | |
root /path/to/app; | |
# change the wildcard with your domain, e.g example.com or *.example.com | |
server_name _; | |
location / { | |
try_files $uri @unicorn_app; | |
} | |
location @unicorn_app { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://unicorn; | |
} | |
location ~ ^/(assets)/ { | |
root /public; | |
gzip_static on; | |
expires 1y; | |
add_header Cache-Control public; | |
add_header ETag ""; | |
} | |
location /doc/ { | |
alias /usr/share/doc/; | |
autoindex on; | |
allow 127.0.0.1; | |
deny all; | |
} | |
# Only for nginx-naxsi : process denied requests | |
# location /RequestDenied { | |
# For example, return an error code | |
# return 418; | |
#} | |
error_page 404 /path/to/public/404.html; | |
error_page 422 /path/to/public/422.html; | |
## | |
# redirect server error pages to the static page /50x.html | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /path/to/public/500.html; | |
} | |
} | |
# HTTPS server | |
# | |
#server { | |
# listen 443; | |
# server_name localhost; | |
# | |
# root html; | |
# index index.html index.htm; | |
# | |
# ssl on; | |
# ssl_certificate cert.pem; | |
# ssl_certificate_key cert.key; | |
# | |
# ssl_session_timeout 5m; | |
# | |
# ssl_protocols SSLv3 TLSv1; | |
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; | |
# ssl_prefer_server_ciphers on; | |
# | |
# location / { | |
# try_files $uri $uri/ /index.html; | |
# } | |
#} |
This file contains 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
# uncomment this line. | |
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment