badger-rails 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. data/BadgerGit.png +0 -0
  2. data/COPYING +674 -0
  3. data/LICENSING +30 -0
  4. data/Manifest +112 -0
  5. data/README.md +80 -0
  6. data/Rakefile +36 -0
  7. data/badger-rails.gemspec +34 -0
  8. data/bin/badger +486 -0
  9. data/lib/badger/Capfile +1 -0
  10. data/lib/badger/config/deploy.rb +211 -0
  11. data/lib/badger/config/rails-app.yml +6 -0
  12. data/lib/badger/config/rails-app.yml.bk +6 -0
  13. data/lib/badger/core/claws/app.claw +112 -0
  14. data/lib/badger/core/claws/db-app.claw +59 -0
  15. data/lib/badger/core/claws/rails-app.claw +125 -0
  16. data/lib/badger/core/files/badger/info +0 -0
  17. data/lib/badger/core/files/cap/Capfile +4 -0
  18. data/lib/badger/core/files/cap/deploy/production-app.rb +139 -0
  19. data/lib/badger/core/files/cap/deploy/production.rb +136 -0
  20. data/lib/badger/core/files/cap/deploy/staging-app.rb +139 -0
  21. data/lib/badger/core/files/cap/deploy/staging.rb +134 -0
  22. data/lib/badger/core/files/cap/deploy.rb +6 -0
  23. data/lib/badger/core/files/git/git +0 -0
  24. data/lib/badger/core/files/god/angel/resque-dev.god +54 -0
  25. data/lib/badger/core/files/god/angel/resque-stg.god +54 -0
  26. data/lib/badger/core/files/god/angel/resque.god +55 -0
  27. data/lib/badger/core/files/god/angel/unicorn-stg.god +62 -0
  28. data/lib/badger/core/files/god/angel/unicorn.god +62 -0
  29. data/lib/badger/core/files/god/god +108 -0
  30. data/lib/badger/core/files/god/unicorn-stg.rb +70 -0
  31. data/lib/badger/core/files/god/unicorn.rb +70 -0
  32. data/lib/badger/core/files/logrotate/logrotate.conf +23 -0
  33. data/lib/badger/core/files/logrotate/logrotate.cron +8 -0
  34. data/lib/badger/core/files/mysql/database.yml.bk +18 -0
  35. data/lib/badger/core/files/mysql/db_stats +0 -0
  36. data/lib/badger/core/files/mysql/my.cnf +11 -0
  37. data/lib/badger/core/files/nginx/nginx +106 -0
  38. data/lib/badger/core/files/nginx/nginx.conf +30 -0
  39. data/lib/badger/core/files/nginx/sites/port443.btl +42 -0
  40. data/lib/badger/core/files/nginx/sites/port80.btl +39 -0
  41. data/lib/badger/core/files/nginx/sites/production-web +117 -0
  42. data/lib/badger/core/files/nginx/sites/staging-web +41 -0
  43. data/lib/badger/core/files/postfix/main.cf +678 -0
  44. data/lib/badger/core/files/postfix/master.cf +81 -0
  45. data/lib/badger/core/files/redis/redis-server +59 -0
  46. data/lib/badger/core/files/redis/redis.conf +444 -0
  47. data/lib/badger/core/files/resque/resque.rb +5 -0
  48. data/lib/badger/core/files/resque/resque.yml +19 -0
  49. data/lib/badger/core/files/resque/resque_web.rb +2 -0
  50. data/lib/badger/core/files/ssh/authorized_keys +0 -0
  51. data/lib/badger/core/functions +174 -0
  52. data/lib/badger/core/scripts/app_info +40 -0
  53. data/lib/badger/core/scripts/app_scale +15 -0
  54. data/lib/badger/core/scripts/remove_app +25 -0
  55. data/lib/badger/core/scripts/remove_app_db +30 -0
  56. data/lib/badger/core/scripts/remove_gems +2 -0
  57. data/lib/badger/core/teeth/automake.th +9 -0
  58. data/lib/badger/core/teeth/badger.th +27 -0
  59. data/lib/badger/core/teeth/bison.th +20 -0
  60. data/lib/badger/core/teeth/bundler.th +4 -0
  61. data/lib/badger/core/teeth/capistrano-ext.th +37 -0
  62. data/lib/badger/core/teeth/chkconfig.th +4 -0
  63. data/lib/badger/core/teeth/curl.th +24 -0
  64. data/lib/badger/core/teeth/faac.th +11 -0
  65. data/lib/badger/core/teeth/ffmpeg.th +28 -0
  66. data/lib/badger/core/teeth/firewall.th +70 -0
  67. data/lib/badger/core/teeth/gcc-c++.th +9 -0
  68. data/lib/badger/core/teeth/gcc.th +9 -0
  69. data/lib/badger/core/teeth/git.th +23 -0
  70. data/lib/badger/core/teeth/god.th +17 -0
  71. data/lib/badger/core/teeth/lame.th +9 -0
  72. data/lib/badger/core/teeth/libffi.th +4 -0
  73. data/lib/badger/core/teeth/libid3tag.th +10 -0
  74. data/lib/badger/core/teeth/libmad.th +11 -0
  75. data/lib/badger/core/teeth/libogg.th +9 -0
  76. data/lib/badger/core/teeth/libtool.th +9 -0
  77. data/lib/badger/core/teeth/libxml2.th +19 -0
  78. data/lib/badger/core/teeth/libxslt.th +19 -0
  79. data/lib/badger/core/teeth/libyaml.th +19 -0
  80. data/lib/badger/core/teeth/logrotate.th +19 -0
  81. data/lib/badger/core/teeth/madplay.th +10 -0
  82. data/lib/badger/core/teeth/make.th +9 -0
  83. data/lib/badger/core/teeth/mysql-config.th +40 -0
  84. data/lib/badger/core/teeth/mysql-server.th +16 -0
  85. data/lib/badger/core/teeth/mysql.th +14 -0
  86. data/lib/badger/core/teeth/nginx.th +56 -0
  87. data/lib/badger/core/teeth/ntp.th +15 -0
  88. data/lib/badger/core/teeth/openssl.th +19 -0
  89. data/lib/badger/core/teeth/pcre.th +9 -0
  90. data/lib/badger/core/teeth/plugins.th +14 -0
  91. data/lib/badger/core/teeth/postfix.th +11 -0
  92. data/lib/badger/core/teeth/pwgen.th +9 -0
  93. data/lib/badger/core/teeth/rake.th +12 -0
  94. data/lib/badger/core/teeth/readline.th +19 -0
  95. data/lib/badger/core/teeth/redis.th +18 -0
  96. data/lib/badger/core/teeth/resque.th +12 -0
  97. data/lib/badger/core/teeth/ruby.th +52 -0
  98. data/lib/badger/core/teeth/rubygems.th +17 -0
  99. data/lib/badger/core/teeth/san_juan.th +4 -0
  100. data/lib/badger/core/teeth/sox.th +12 -0
  101. data/lib/badger/core/teeth/speex.th +12 -0
  102. data/lib/badger/core/teeth/sqlite3.th +14 -0
  103. data/lib/badger/core/teeth/ssh_keys.th +10 -0
  104. data/lib/badger/core/teeth/sshpass.th +9 -0
  105. data/lib/badger/core/teeth/sudo.th +9 -0
  106. data/lib/badger/core/teeth/syslog-ng.th +16 -0
  107. data/lib/badger/core/teeth/sysv-rc-conf.th +4 -0
  108. data/lib/badger/core/teeth/x264.th +11 -0
  109. data/lib/badger/core/teeth/xvid.th +11 -0
  110. data/lib/badger/core/teeth/yasm.th +11 -0
  111. data/lib/badger/core/teeth/zlib.th +9 -0
  112. data/lib/core.rb +313 -0
  113. data/lib/errors.rb +202 -0
  114. metadata +297 -0
@@ -0,0 +1,70 @@
1
+ rails_env = ENV['RAILS_ENV'] || 'staging'
2
+
3
+ # 16 workers and 1 master
4
+ worker_processes 2
5
+
6
+ # Load rails+github.git into the master before forking workers
7
+ # for super-fast worker spawn times
8
+ preload_app true
9
+
10
+ # Restart any workers that haven't responded in 30 seconds
11
+ timeout 90
12
+
13
+ # Listen on a Unix data socket
14
+ listen '/tmp/unicorn.sock'
15
+
16
+ working_directory "/opt/web/current"
17
+ pid "/opt/web/shared/pids/unicorn.pid"
18
+
19
+ stderr_path "/opt/web/shared/log/unicorn.stderr.log"
20
+ stdout_path "/opt/web/shared/log/unicorn.stdout.log"
21
+
22
+ before_fork do |server, worker|
23
+ ##
24
+ # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
25
+ # immediately start loading up a new version of itself (loaded with a new
26
+ # version of our app). When this new Unicorn is completely loaded
27
+ # it will begin spawning workers. The first worker spawned will check to
28
+ # see if an .oldbin pidfile exists. If so, this means we've just booted up
29
+ # a new Unicorn and need to tell the old one that it can now die. To do so
30
+ # we send it a QUIT.
31
+ #
32
+ # Using this method we get 0 downtime deploys.
33
+
34
+ defined?(ActiveRecord::Base) and
35
+ ActiveRecord::Base.connection.disconnect!
36
+
37
+ old_pid = '/opt/web/shared/pids/unicorn.pid.oldbin'
38
+ if File.exists?(old_pid) && server.pid != old_pid
39
+ begin
40
+ Process.kill("QUIT", File.read(old_pid).to_i)
41
+ rescue Errno::ENOENT, Errno::ESRCH
42
+ # someone else did our job for us
43
+ end
44
+ end
45
+ end
46
+
47
+ after_fork do |server, worker|
48
+ defined?(ActiveRecord::Base) and
49
+ ActiveRecord::Base.establish_connection
50
+
51
+ begin
52
+ uid, gid = Process.euid, Process.egid
53
+ user, group = 'badger', 'badger'
54
+ target_uid = Etc.getpwnam(user).uid
55
+ target_gid = Etc.getgrnam(group).gid
56
+ worker.tmp.chown(target_uid, target_gid)
57
+ if uid != target_uid || gid != target_gid
58
+ Process.initgroups(user, target_gid)
59
+ Process::GID.change_privilege(target_gid)
60
+ Process::UID.change_privilege(target_uid)
61
+ end
62
+ rescue => e
63
+ if rails_env == 'staging'
64
+ STDERR.puts "couldn't change user, oh well"
65
+ else
66
+ raise e
67
+ end
68
+ end
69
+
70
+ end
@@ -0,0 +1,70 @@
1
+ rails_env = ENV['RAILS_ENV'] || 'production'
2
+
3
+ # 16 workers and 1 master
4
+ worker_processes 2
5
+
6
+ # Load rails+github.git into the master before forking workers
7
+ # for super-fast worker spawn times
8
+ preload_app true
9
+
10
+ # Restart any workers that haven't responded in 30 seconds
11
+ timeout 30
12
+
13
+ # Listen on a Unix data socket
14
+ listen '/tmp/unicorn.sock'
15
+
16
+ working_directory "/opt/web/current"
17
+ pid "/opt/web/shared/pids/unicorn.pid"
18
+
19
+ stderr_path "/opt/web/shared/log/unicorn.stderr.log"
20
+ stdout_path "/opt/web/shared/log/unicorn.stdout.log"
21
+
22
+ before_fork do |server, worker|
23
+ ##
24
+ # When sent a USR2, Unicorn will suffix its pidfile with .oldbin and
25
+ # immediately start loading up a new version of itself (loaded with a new
26
+ # version of our app). When this new Unicorn is completely loaded
27
+ # it will begin spawning workers. The first worker spawned will check to
28
+ # see if an .oldbin pidfile exists. If so, this means we've just booted up
29
+ # a new Unicorn and need to tell the old one that it can now die. To do so
30
+ # we send it a QUIT.
31
+ #
32
+ # Using this method we get 0 downtime deploys.
33
+
34
+ defined?(ActiveRecord::Base) and
35
+ ActiveRecord::Base.connection.disconnect!
36
+
37
+ old_pid = '/opt/web/shared/pids/unicorn.pid.oldbin'
38
+ if File.exists?(old_pid) && server.pid != old_pid
39
+ begin
40
+ Process.kill("QUIT", File.read(old_pid).to_i)
41
+ rescue Errno::ENOENT, Errno::ESRCH
42
+ # someone else did our job for us
43
+ end
44
+ end
45
+ end
46
+
47
+ after_fork do |server, worker|
48
+ defined?(ActiveRecord::Base) and
49
+ ActiveRecord::Base.establish_connection
50
+
51
+ begin
52
+ uid, gid = Process.euid, Process.egid
53
+ user, group = 'badger', 'badger'
54
+ target_uid = Etc.getpwnam(user).uid
55
+ target_gid = Etc.getgrnam(group).gid
56
+ worker.tmp.chown(target_uid, target_gid)
57
+ if uid != target_uid || gid != target_gid
58
+ Process.initgroups(user, target_gid)
59
+ Process::GID.change_privilege(target_gid)
60
+ Process::UID.change_privilege(target_uid)
61
+ end
62
+ rescue => e
63
+ if rails_env == 'development'
64
+ STDERR.puts "couldn't change user, oh well"
65
+ else
66
+ raise e
67
+ end
68
+ end
69
+
70
+ end
@@ -0,0 +1,23 @@
1
+ weekly
2
+
3
+ rotate 4
4
+
5
+ create
6
+
7
+ include /etc/logrotate.d
8
+
9
+ /var/log/wtmp {
10
+ missingok
11
+ monthly
12
+ create 0664 root utmp
13
+ rotate 48
14
+ olddir /var/log/archive
15
+ }
16
+
17
+ /var/log/btmp {
18
+ missingok
19
+ monthly
20
+ create 0664 root utmp
21
+ rotate 48
22
+ olddir /var/log/archive
23
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+
3
+ /usr/sbin/logrotate /etc/logrotate.conf
4
+ EXITVALUE=$?
5
+ if [ $EXITVALUE != 0 ]; then
6
+ /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
7
+ fi
8
+ exit 0
@@ -0,0 +1,18 @@
1
+
2
+ staging:
3
+ host: localhost
4
+ username: badger
5
+ password: example
6
+ database: badger-staging
7
+ adapter: mysql2
8
+ reconnect: true
9
+ pool: 100
10
+
11
+ production:
12
+ host: localhost
13
+ username: badger
14
+ password: example
15
+ database: badger-production
16
+ adapter: mysql2
17
+ reconnect: true
18
+ pool: 100
File without changes
@@ -0,0 +1,11 @@
1
+ [mysqldump]
2
+ user = root
3
+ password = root_password
4
+
5
+ [mysql]
6
+ user = root
7
+ password = root_password
8
+
9
+ [mysqladmin]
10
+ user = root
11
+ password = root_password
@@ -0,0 +1,106 @@
1
+ #!/bin/sh
2
+ #
3
+ # nginx - this script starts and stops the nginx daemin
4
+ #
5
+ # chkconfig: - 85 15
6
+ # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
7
+ # proxy and IMAP/POP3 proxy server
8
+ # processname: nginx
9
+ # config: /usr/local/nginx/conf/nginx.conf
10
+ # pidfile: /usr/local/nginx/logs/nginx.pid
11
+
12
+ # Source function library.
13
+ . /etc/rc.d/init.d/functions
14
+
15
+ # Source networking configuration.
16
+ . /etc/sysconfig/network
17
+
18
+ # Check that networking is up.
19
+ [ "$NETWORKING" = "no" ] && exit 0
20
+
21
+ nginx="/usr/sbin/nginx"
22
+ prog=$(basename $nginx)
23
+
24
+ NGINX_CONF_FILE="/etc/nginx/nginx.conf"
25
+
26
+ lockfile=/var/lock/subsys/nginx
27
+
28
+ start() {
29
+ [ -x $nginx ] || exit 5
30
+ [ -f $NGINX_CONF_FILE ] || exit 6
31
+ echo -n $"Starting $prog: "
32
+ daemon $nginx -c $NGINX_CONF_FILE
33
+ retval=$?
34
+ echo
35
+ [ $retval -eq 0 ] && touch $lockfile
36
+ return $retval
37
+ }
38
+
39
+ stop() {
40
+ echo -n $"Stopping $prog: "
41
+ killproc $prog -QUIT
42
+ retval=$?
43
+ echo
44
+ [ $retval -eq 0 ] && rm -f $lockfile
45
+ return $retval
46
+ }
47
+
48
+ restart() {
49
+ configtest || return $?
50
+ stop
51
+ start
52
+ }
53
+
54
+ reload() {
55
+ configtest || return $?
56
+ echo -n $"Reloading $prog: "
57
+ killproc $nginx -HUP
58
+ RETVAL=$?
59
+ echo
60
+ }
61
+
62
+ force_reload() {
63
+ restart
64
+ }
65
+
66
+ configtest() {
67
+ $nginx -t -c $NGINX_CONF_FILE
68
+ }
69
+
70
+ rh_status() {
71
+ status $prog
72
+ }
73
+
74
+ rh_status_q() {
75
+ rh_status >/dev/null 2>&1
76
+ }
77
+
78
+ case "$1" in
79
+ start)
80
+ rh_status_q && exit 0
81
+ $1
82
+ ;;
83
+ stop)
84
+ rh_status_q || exit 0
85
+ $1
86
+ ;;
87
+ restart|configtest)
88
+ $1
89
+ ;;
90
+ reload)
91
+ rh_status_q || exit 7
92
+ $1
93
+ ;;
94
+ force-reload)
95
+ force_reload
96
+ ;;
97
+ status)
98
+ rh_status
99
+ ;;
100
+ condrestart|try-restart)
101
+ rh_status_q || exit 0
102
+ ;;
103
+ *)
104
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
105
+ exit 2
106
+ esac
@@ -0,0 +1,30 @@
1
+ user badger;
2
+ worker_processes 2;
3
+
4
+ error_log /var/log/nginx/error.log;
5
+ pid /var/run/nginx.pid;
6
+
7
+ events {
8
+ worker_connections 1024;
9
+ }
10
+
11
+ http {
12
+ include /etc/nginx/mime.types;
13
+
14
+ access_log /var/log/nginx/access.log;
15
+
16
+ sendfile on;
17
+ #tcp_nopush on;
18
+
19
+ #keepalive_timeout 0;
20
+ keepalive_timeout 65;
21
+ tcp_nodelay on;
22
+
23
+ gzip on;
24
+ gzip_disable "MSIE [1-6]\.(?!.*SV1)";
25
+
26
+ include /etc/nginx/conf.d/*.conf;
27
+ include /etc/nginx/sites-enabled/*;
28
+
29
+ server_tokens off;
30
+ }
@@ -0,0 +1,42 @@
1
+ cat >> /etc/badger/core/files/nginx/sites/production-web << EOF
2
+
3
+ server {
4
+ listen 443;
5
+ ssl on;
6
+ ssl_certificate /etc/ssl/${domain}.crt;
7
+ ssl_certificate_key /etc/ssl/${domain}.key;
8
+
9
+ client_max_body_size 4G;
10
+ server_name ${domain};
11
+ access_log /var/log/nginx/nginx.ssl.access.log;
12
+ error_log /var/log/nginx/nginx.ssl.error.log;
13
+
14
+ root /opt/web/current/public;
15
+ keepalive_timeout 5;
16
+
17
+ location / {
18
+ proxy_set_header X-Forwarded-Proto https;
19
+ proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
20
+ proxy_set_header Host \$http_host;
21
+ proxy_redirect off;
22
+
23
+ if (!-f \$request_filename) {
24
+ proxy_pass http://production-web;
25
+ break;
26
+ }
27
+ }
28
+
29
+ location ~ ^/assets/ {
30
+ expires 1y;
31
+ add_header Cache-Control public;
32
+ add_header ETag "";
33
+ break;
34
+ }
35
+
36
+ error_page 500 502 503 504 /500.html;
37
+ location = /500.html {
38
+ root /opt/web/current/public;
39
+ }
40
+
41
+ }
42
+ EOF
@@ -0,0 +1,39 @@
1
+ cat > /etc/badger/core/files/nginx/sites/production-web << EOF
2
+ upstream production-web {
3
+ server unix:/tmp/unicorn.sock fail_timeout=0;
4
+ }
5
+
6
+ server {
7
+ listen 80 default;
8
+
9
+ client_max_body_size 4G;
10
+ server_name www.${domain} ${domain};
11
+ root /opt/web/current/public;
12
+ keepalive_timeout 5;
13
+
14
+ location / {
15
+ proxy_set_header X-Forwarded-Proto \$scheme;
16
+ proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
17
+ proxy_set_header Host \$http_host;
18
+ proxy_redirect off;
19
+
20
+ if (!-f \$request_filename) {
21
+ proxy_pass http://production-web;
22
+ break;
23
+ }
24
+ }
25
+
26
+ location ~ ^/assets/ {
27
+ expires 1y;
28
+ add_header Cache-Control public;
29
+ add_header ETag "";
30
+ break;
31
+ }
32
+
33
+ error_page 500 502 503 504 /500.html;
34
+ location = /500.html {
35
+ root /opt/web/current/public;
36
+ }
37
+
38
+ }
39
+ EOF
@@ -0,0 +1,117 @@
1
+ upstream production-web {
2
+ server unix:/tmp/unicorn.sock fail_timeout=0;
3
+ }
4
+
5
+ server {
6
+ listen 80 default;
7
+
8
+ client_max_body_size 4G;
9
+ server_name www.bla.com bla.com;
10
+ root /opt/web/current/public;
11
+ keepalive_timeout 5;
12
+
13
+ location / {
14
+ proxy_set_header X-Forwarded-Proto $scheme;
15
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16
+ proxy_set_header Host $http_host;
17
+ proxy_redirect off;
18
+
19
+ if (!-f $request_filename) {
20
+ proxy_pass http://production-web;
21
+ break;
22
+ }
23
+ }
24
+
25
+ location ~ ^/assets/ {
26
+ expires 1y;
27
+ add_header Cache-Control public;
28
+ add_header ETag "";
29
+ break;
30
+ }
31
+
32
+ error_page 500 502 503 504 /500.html;
33
+ location = /500.html {
34
+ root /opt/web/current/public;
35
+ }
36
+
37
+ }
38
+
39
+ server {
40
+ listen 443;
41
+ ssl on;
42
+ ssl_certificate /etc/ssl/bla.com.crt;
43
+ ssl_certificate_key /etc/ssl/www.bla.com.key;
44
+
45
+ client_max_body_size 4G;
46
+ server_name tryfixup.com;
47
+ access_log /var/log/nginx/nginx.ssl.access.log;
48
+ error_log /var/log/nginx/nginx.ssl.error.log;
49
+
50
+ root /opt/web/current/public;
51
+ keepalive_timeout 5;
52
+
53
+ location / {
54
+ proxy_set_header X-Forwarded-Proto https;
55
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
56
+ proxy_set_header Host $http_host;
57
+ proxy_redirect off;
58
+
59
+ if (!-f $request_filename) {
60
+ proxy_pass http://production-web;
61
+ break;
62
+ }
63
+ }
64
+
65
+ location ~ ^/assets/ {
66
+ expires 1y;
67
+ add_header Cache-Control public;
68
+ add_header ETag "";
69
+ break;
70
+ }
71
+
72
+ error_page 500 502 503 504 /500.html;
73
+ location = /500.html {
74
+ root /opt/web/current/public;
75
+ }
76
+
77
+ }
78
+
79
+ server {
80
+ listen 443;
81
+ ssl on;
82
+ ssl_certificate /etc/ssl/api.bla.com.crt;
83
+ ssl_certificate_key /etc/ssl/api.bla.com.key;
84
+
85
+ client_max_body_size 4G;
86
+ server_name api.bla.com;
87
+ access_log /var/log/nginx/nginx.ssl.access.log;
88
+ error_log /var/log/nginx/nginx.ssl.error.log;
89
+
90
+ root /opt/web/current/public;
91
+ keepalive_timeout 5;
92
+
93
+ location / {
94
+ proxy_set_header X-Forwarded-Proto https;
95
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
96
+ proxy_set_header Host $http_host;
97
+ proxy_redirect off;
98
+
99
+ if (!-f $request_filename) {
100
+ proxy_pass http://production-web;
101
+ break;
102
+ }
103
+ }
104
+
105
+ location ~ ^/assets/ {
106
+ expires 1y;
107
+ add_header Cache-Control public;
108
+ add_header ETag "";
109
+ break;
110
+ }
111
+
112
+ error_page 500 502 503 504 /500.html;
113
+ location = /500.html {
114
+ root /opt/web/current/public;
115
+ }
116
+
117
+ }
@@ -0,0 +1,41 @@
1
+ upstream staging-web {
2
+ server unix:/tmp/unicorn.sock fail_timeout=0;
3
+ }
4
+
5
+ server {
6
+ listen 80 default;
7
+
8
+ client_max_body_size 4G;
9
+ server_name _;
10
+ root /opt/web/current/public;
11
+ keepalive_timeout 90;
12
+
13
+ location / {
14
+ proxy_set_header X-Forwarded-Proto $scheme;
15
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16
+ proxy_set_header Host $http_host;
17
+ proxy_redirect off;
18
+
19
+ if (!-f $request_filename) {
20
+ proxy_pass http://staging-web;
21
+ break;
22
+ }
23
+ }
24
+
25
+ location ~ ^/assets/ {
26
+ expires 1y;
27
+ add_header Cache-Control public;
28
+ add_header ETag "";
29
+ break;
30
+ }
31
+
32
+ error_page 500 502 503 504 /500.html;
33
+ error_page 404 /404.html;
34
+ location = /404.html {
35
+ root /opt/web/current/public;
36
+ }
37
+ location = /500.html {
38
+ root /opt/web/current/public;
39
+ }
40
+
41
+ }