File tree Expand file tree Collapse file tree 4 files changed +35
-9
lines changed
etc/nginx/sites-available Expand file tree Collapse file tree 4 files changed +35
-9
lines changed Original file line number Diff line number Diff line change 3
3
4
4
# Install pre-reqs, security updates
5
5
RUN apt-get update && \
6
+ apt-get upgrade -yq && \
6
7
apt-get -yq install \
7
8
openssl=1.0.1f-1ubuntu2.15 \
8
9
ca-certificates=20141019ubuntu0.14.04.1 \
Original file line number Diff line number Diff line change 1
1
# docker-nginx
2
2
Provides base OS, patches and stable nginx for quick and easy spinup
3
+
4
+
5
+ Variable | Example | Description
6
+ --- | --- | ---
7
+ ` SERVER_MAX_BODY_SIZE ` | ` SERVER_MAX_BODY_SIZE=4M ` | Allows the downstream application to specify a non-default ` client_max_body_size ` configuration for the ` server ` -level directive in ` /etc/nginx/sites-available/default `
8
+ ` SERVER_INDEX ` | `SERVER_INDEX index.html index.html index.php | Changes the default pages to hit for folder and web roots
Original file line number Diff line number Diff line change
1
+ # NOTE: the syntax in most directives is sadly duplicated in run.sh,
2
+ # in order to replace at runtime with `sed`, therefore, check for changes in both places
1
3
server {
2
4
listen 80;
3
5
4
6
server_tokens off; # Doesn't broadcast version level of server software
5
- server_name web; # TODO: replace with environment variable
6
7
8
+ # Replace with env variable SERVER_INDEX
7
9
index index.html index.htm;
8
10
11
+ # Replace with env variable SERVER_MAX_BODY_SIZE
12
+ client_max_body_size 1m;
13
+
9
14
location / {
10
- # Check for file or folder first, otherwise rewrite to front controller
11
15
try_files $uri $uri/ =404;
12
16
}
13
17
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
+ CONFIG_SITE=/etc/nginx/sites-available/default
3
+ CONFIG_SERVER=/etc/nginx/nginx.conf
2
4
3
- echo ' Setting sensible nginx defaults'
5
+ echo ' [nginx] setting sensible defaults'
4
6
5
7
# Configure nginx to use as many workers as there are cores for the running container
6
- sed -i " s/worker_processes [0-9]\+/worker_processes $( nproc) /" /etc/nginx/nginx.conf
7
- sed -i " s/worker_connections [0-9]\+/worker_connections 1024/" /etc/nginx/nginx.conf
8
+ sed -i " s/worker_processes [0-9]\+/worker_processes $( nproc) /" $CONFIG_SERVER
9
+ sed -i " s/worker_connections [0-9]\+/worker_connections 1024/" $CONFIG_SERVER
8
10
9
- # Ensure nginx is configured to write logs to STDOUT
10
- sed -i " s/access_log [a-z\/\.\;]\+/access_log \/dev\/stdout;/" /etc/nginx/nginx.conf
11
- sed -i " s/error_log [a-z\/\.\ \;]\+/error_log \/dev\/stdout info;/" /etc/nginx/nginx.conf
11
+ echo ' [nginx] piping logs to STDOUT'
12
12
13
- echo " Starting Nginx (foreground)"
13
+ sed -i " s/access_log [a-z\/\.\;]\+/access_log \/dev\/stdout;/" $CONFIG_SERVER
14
+ sed -i " s/error_log [a-z\/\.\ \;]\+/error_log \/dev\/stdout info;/" $CONFIG_SERVER
15
+
16
+ if [[ $SERVER_MAX_BODY_SIZE ]]
17
+ then
18
+ echo " [nginx] server client max body is ${SERVER_MAX_BODY_SIZE} "
19
+ sed -i " s/client_max_body_size 1m/client_max_body_size ${SERVER_MAX_BODY_SIZE} /" $CONFIG_SITE
20
+ fi
21
+
22
+ if [[ $SERVER_INDEX ]]
23
+ then
24
+ echo " [nginx] server index is ${SERVER_INDEX} "
25
+ sed -i " s/index index.html index.htm/index ${SERVER_INDEX} /" $CONFIG_SITE
26
+ fi
27
+
28
+ echo " [nginx] starting (foreground)"
14
29
exec /usr/sbin/nginx -g " daemon off;"
You can’t perform that action at this time.
0 commit comments