Last active
February 28, 2020 11:35
-
-
Save nesquena/485042 to your computer and use it in GitHub Desktop.
nginx configuration
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
worker_processes 4; | |
error_log logs/error.log; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
# Passenger global settings | |
passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-2.2.15; | |
passenger_ruby /usr/local/bin/ruby; | |
passenger_max_pool_size 10; | |
passenger_pool_idle_time 0; | |
passenger_max_instances_per_app 0; | |
include mime.types; | |
default_type application/octet-stream; | |
access_log logs/access.log; | |
sendfile on; | |
keepalive_timeout 65; | |
tcp_nodelay on; | |
tcp_nopush on; | |
gzip on; | |
gzip_comp_level 2; | |
gzip_proxied any; | |
gzip_buffers 16 8k; | |
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
gzip_disable "MSIE [1-6].(?!.*SV1)"; | |
server { | |
listen 80; | |
server_name demo.com; | |
root /var/apps/demo/current/public; | |
# Passenger server specific settings | |
passenger_enabled on; | |
rails_spawn_method smart; | |
rack_env production; | |
# Rewrites to maintenance page for capistrano if exists. | |
if (-f $document_root/system/maintenance.html){ | |
rewrite ^(.*)$ /system/maintenance.html break; | |
} | |
# Rewrite www.demo.com --> demo.com | |
if ($host != 'demo.com' ) { | |
rewrite ^/(.*)$ http://demo.com/$1 permanent; | |
} | |
# Sets an expires header for any assets with a query string | |
location ~* (stylesheets|javascripts|images) { | |
if (!-f $request_filename) { | |
break; | |
} | |
if ($query_string ~* "^[0-9]{10}$") { | |
expires max; | |
break; | |
} | |
} | |
# error_page 500 502 503 504 /50x.html; | |
# location = /50x.html { | |
# root html; | |
# } | |
} | |
server { | |
listen 443; | |
server_name demo.com; | |
root /var/apps/demo/current/public; | |
passenger_enabled on; | |
rack_env production; | |
ssl on; | |
ssl_certificate ssl/demo.com.crt; | |
ssl_certificate_key ssl/demo.com.key; | |
ssl_session_timeout 5m; | |
ssl_protocols SSLv2 SSLv3 TLSv1; | |
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; | |
ssl_prefer_server_ciphers on; | |
# needed for HTTPS | |
proxy_set_header X_FORWARDED_PROTO https; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_max_temp_file_size 0; | |
# needed to forward user's IP address to rails | |
proxy_set_header X-Real-IP $remote_addr; | |
# Rewrites to maintenance page for capistrano if exists. | |
if (-f $document_root/system/maintenance.html){ | |
rewrite ^(.*)$ /system/maintenance.html break; | |
} | |
# Rewrite www.demo.com --> demo.com | |
if ($host != 'demo.com' ) { | |
rewrite ^/(.*)$ http://demo.com/$1 permanent; | |
} | |
# Sets an expires header for any assets with a query string | |
location ~* (stylesheets|javascripts|images) { | |
if (!-f $request_filename) { | |
break; | |
} | |
if ($query_string ~* "^[0-9]{10}$") { | |
expires max; | |
break; | |
} | |
} | |
# error_page 500 502 503 504 /50x.html; | |
# location = /50x.html { | |
# root html; | |
# } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment