Skip to content

Commit

Permalink
Merge pull request #9 from spreedly/CX-1449_upgrade-nginx-version-bui…
Browse files Browse the repository at this point in the history
…lpack

updates for new nginx buildpak
  • Loading branch information
yyapuncich authored Jan 19, 2024
2 parents 400c5c2 + 37f0314 commit 6d17b53
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: bin/start_nginx
web: bin/start-nginx-static
46 changes: 0 additions & 46 deletions conf/nginx.conf.erb

This file was deleted.

File renamed without changes.
73 changes: 73 additions & 0 deletions config/nginx.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# much of this config from heroku-community/nginx repo

daemon off;
# Heroku dynos have at least 4 cores.

worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
# Heroku dynos have at least 4 cores.

pid /app/nginx.pid;
# /app is $HOME & working directory of Heroku dyno

error_log stderr info;
# As documented for Nginx, but we still see error during start-up in log:
# > nginx: [alert] could not open error log file: open() "./logs/error.log"

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 /dev/stdout l2met;
# Remote IP, request path, HTTP status, & timestamp are all logged by Heroku Router, so not useful to include here.

include mime.types;
default_type application/octet-stream;
sendfile on;

client_body_timeout <%= ENV['NGINX_CLIENT_BODY_TIMEOUT'] || 10 %>;
# Must read the body in 10 seconds.

port_in_redirect off;

server {

listen <%= ENV['PORT'] %>;
server_name <%= ENV['HOST'] || 'localhost' %>;
keepalive_timeout 25;

## HTTPS Only
if ($http_x_forwarded_proto != "https") {
return 301 https://$host$request_uri;
}

add_header Vary Accept-Encoding;
add_header Cache-Control public;

# Block certain file access
# Ideas from this post https://serverfault.com/a/1069003
location ~\.(md|git|txt|json|log)|(Procfile|README|LICENSE)+.*?$ {
deny all;
return 404;
}

# Generated site at "public" root dir
location / {
root /app/;
limit_except GET HEAD POST { deny all; }
# expires <%= ENV['DEFAULT_TTL'] || 3600 %>s;
expires max;
try_files $uri $uri/ $uri.html index.html;
}
}
}
75 changes: 75 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
"start": "static ."
},
"engines": {
"node": "0.10.x"
"node": "^16.15.0"
},
"dependencies": {
"node-static": "^0.7.6"
},
"author": "Ryan Daigle"
"node-static": "^0.7.11"
}
}

0 comments on commit 6d17b53

Please sign in to comment.