-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-boot.sh
executable file
·68 lines (55 loc) · 1.59 KB
/
nginx-boot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
export NGINX_CONF=/etc/nginx/mushed.conf
export GZIP_TYPES=${GZIP_TYPES:-application/javascript application/x-javascript application/rss+xml text/javascript text/css image/svg+xml}
export GZIP_LEVEL=${GZIP_LEVEL:-6}
export INDEX_FILE=/usr/share/nginx/html/index.html
# cat $INDEX_FILE | sed 's/_TEMPLATE//g' | envsubst > /tmp/index.html
# mv /tmp/index.html $INDEX_FILE
cat <<EOF > $NGINX_CONF
daemon off;
worker_processes 1;
user root;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 15;
autoindex off;
server_tokens off;
port_in_redirect off;
absolute_redirect off;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
client_max_body_size 64k;
client_header_buffer_size 16k;
large_client_header_buffers 4 16k;
## Gzipping is an easy way to reduce page weight
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_types $GZIP_TYPES;
gzip_buffers 16 8k;
gzip_comp_level $GZIP_LEVEL;
access_log /dev/stdout;
error_log /dev/stderr error;
server {
listen ${PORT:-80};
root /usr/share/nginx/html;
index index.html;
autoindex off;
charset utf-8;
error_page 404 /404.html;
location / {
try_files \$uri /index.html =404;
}
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|jsx|css|less|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
expires +1y;
}
}
}
EOF
exec nginx -c $NGINX_CONF