-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use nginx instead of webrick when hosting on Heroku (#156)
This uses the heroku NGINX buildpack to serve up the static files instead of a ruby process. This is better in prod than webrick, as it is a proper webserver that can handle more than one request at a time. This will do while we sort out Cloudflare buckets etc.
- Loading branch information
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
web: ruby -run -e httpd -- -p $PORT build/ | ||
web: bin/start-nginx-solo |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
"buildpacks": [ | ||
{ | ||
"url": "heroku/nodejs" | ||
}, | ||
{ | ||
"url": "https://github.com/heroku/heroku-buildpack-nginx" | ||
} | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
daemon off; | ||
# Heroku dynos have at least 4 cores. | ||
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>; | ||
|
||
events { | ||
use epoll; | ||
accept_mutex on; | ||
worker_connections <%= ENV['NGINX_WORKER_CONNECTIONS'] || 1024 %>; | ||
} | ||
|
||
http { | ||
gzip on; | ||
gzip_comp_level 2; | ||
gzip_min_length 512; | ||
gzip_proxied any; # Heroku router sends Via header | ||
|
||
server_tokens off; | ||
|
||
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id'; | ||
access_log <%= ENV['NGINX_ACCESS_LOG_PATH'] || 'logs/nginx/access.log' %> l2met; | ||
error_log <%= ENV['NGINX_ERROR_LOG_PATH'] || 'logs/nginx/error.log' %>; | ||
|
||
|
||
include mime.types; | ||
default_type application/octet-stream; | ||
sendfile on; | ||
|
||
# Must read the body in 5 seconds. | ||
client_body_timeout <%= ENV['NGINX_CLIENT_BODY_TIMEOUT'] || 5 %>; | ||
|
||
server { | ||
listen <%= ENV["PORT"] %>; | ||
server_name _; | ||
keepalive_timeout 5; | ||
client_max_body_size <%= ENV['NGINX_CLIENT_MAX_BODY_SIZE'] || 1 %>M; | ||
|
||
root /app/build; # path to your app | ||
} | ||
} |