| 1 |
# Ignore 4xx errors which we get a bunch of those in |
| 2 |
# the file browser version switcher - e.g. when viewing the |
| 3 |
# README.md file of version 1.0.0, there are links to the |
| 4 |
# same file in other versions, but it may be absent, thus |
| 5 |
# a 404 error. |
| 6 |
# We don't want elastic beanstalk replace instances because |
| 7 |
# of those 404 errors. |
| 8 |
# See https://stackoverflow.com/a/49606726/267998 |
| 9 |
files: |
| 10 |
"/tmp/custom-site-nginx.conf": |
| 11 |
mode: "000664" |
| 12 |
owner: root |
| 13 |
group: root |
| 14 |
content: | |
| 15 |
map $http_upgrade $connection_upgrade { |
| 16 |
default "upgrade"; |
| 17 |
"" ""; |
| 18 |
} |
| 19 |
|
| 20 |
# Elastic Beanstalk Modification(EB_INCLUDE) |
| 21 |
# Custom config |
| 22 |
# HTTP 4xx ignored. |
| 23 |
map $status $loggable { |
| 24 |
~^[4] 0; |
| 25 |
default 1; |
| 26 |
} |
| 27 |
|
| 28 |
server { |
| 29 |
listen 80; |
| 30 |
|
| 31 |
gzip on; |
| 32 |
gzip_comp_level 4; |
| 33 |
gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; |
| 34 |
|
| 35 |
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") { |
| 36 |
set $year $1; |
| 37 |
set $month $2; |
| 38 |
set $day $3; |
| 39 |
set $hour $4; |
| 40 |
} |
| 41 |
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd if=$loggable; |
| 42 |
|
| 43 |
access_log /var/log/nginx/access.log; |
| 44 |
|
| 45 |
location / { |
| 46 |
proxy_pass http://docker; |
| 47 |
proxy_http_version 1.1; |
| 48 |
|
| 49 |
proxy_set_header Connection $connection_upgrade; |
| 50 |
proxy_set_header Upgrade $http_upgrade; |
| 51 |
proxy_set_header Host $host; |
| 52 |
proxy_set_header X-Real-IP $remote_addr; |
| 53 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 54 |
} |
| 55 |
} |
| 56 |
container_commands: |
| 57 |
override_beanstalk_nginx: |
| 58 |
command: "mv -f /tmp/custom-site-nginx.conf /etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy.conf" |