summaryrefslogtreecommitdiff
path: root/nginx.sh
blob: b0c6cad0d1e6f501baa670df0dd47a6d1fa9bd0b (plain)
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
#!/bin/bash

cd "$(dirname $0)"

# empty file
> nginx.gen.conf

V="$(nginx -V 2>&1)"

check() {
  if [[ "$V" == *"$1"* ]]; then
    if [[ -n "$3" ]]; then
      echo "$2" >> nginx.gen.conf
    fi
  else
    if [[ -n "$3" ]]; then
      echo "$3" >> nginx.gen.conf
    fi
    if [[ -n "$4" ]]; then
      echo "$4" >&2
    fi
  fi
}

check --with-http_gzip_static_module "gzip_static on;" "" "The gzip_static module for nginx is highly recommended to reduce server load and utilize zopfli's higher compression ratio."

check --without-http_proxy_module "" "proxy_temp_path /dev/null;"
check --without-http_fastcgi_module "" "fastcgi_temp_path /dev/null;"
check --without-http_scgi_module "" "scgi_temp_path /dev/null;"
check --without-http_uwsgi_module "" "uwsgi_temp_path /dev/null;"

echo "Ignore any following messages from nginx about the error log." >&2
exec nginx -p "$PWD/" -c nginx.conf