2017-12-21 09:02:37 +10:00
|
|
|
#!/usr/bin/with-contenv bash
|
|
|
|
|
2018-10-19 16:24:44 +10:00
|
|
|
# Create required folders
|
2018-08-02 19:48:47 +10:00
|
|
|
mkdir -p /tmp/nginx/body \
|
|
|
|
/var/log/nginx \
|
2018-08-21 08:33:51 +10:00
|
|
|
/data/nginx \
|
2018-08-22 14:31:03 +10:00
|
|
|
/data/custom_ssl \
|
2018-08-21 08:33:51 +10:00
|
|
|
/data/logs \
|
|
|
|
/data/access \
|
2019-03-04 21:19:36 +10:00
|
|
|
/data/nginx/default_host \
|
|
|
|
/data/nginx/default_www \
|
2018-08-21 08:33:51 +10:00
|
|
|
/data/nginx/proxy_host \
|
|
|
|
/data/nginx/redirection_host \
|
|
|
|
/data/nginx/stream \
|
|
|
|
/data/nginx/dead_host \
|
|
|
|
/data/nginx/temp \
|
|
|
|
/var/lib/nginx/cache/public \
|
2018-11-05 10:58:22 +11:00
|
|
|
/var/lib/nginx/cache/private \
|
|
|
|
/var/cache/nginx/proxy_temp
|
2018-07-31 15:18:09 +10:00
|
|
|
|
2018-11-05 10:58:22 +11:00
|
|
|
touch /var/log/nginx/error.log && chmod 777 /var/log/nginx/error.log && chmod -R 777 /var/cache/nginx
|
2017-12-21 09:02:37 +10:00
|
|
|
chown root /tmp/nginx
|
2018-07-31 15:18:09 +10:00
|
|
|
|
2020-01-05 17:48:43 -05:00
|
|
|
# Dynamically generate resolvers file, if resolver is IPv6, enclose in `[]`
|
|
|
|
echo resolver $(awk 'BEGIN{ORS=" "} $1=="nameserver" {print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf) ";" > /etc/nginx/conf.d/include/resolvers.conf
|
2018-10-19 16:24:44 +10:00
|
|
|
|
2018-11-02 10:06:37 -04:00
|
|
|
# Generate dummy self-signed certificate.
|
|
|
|
if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]
|
|
|
|
then
|
2018-11-05 10:58:22 +11:00
|
|
|
echo "Generating dummy SSL certificate..."
|
2018-11-02 10:06:37 -04:00
|
|
|
openssl req \
|
|
|
|
-new \
|
|
|
|
-newkey rsa:2048 \
|
|
|
|
-days 3650 \
|
|
|
|
-nodes \
|
|
|
|
-x509 \
|
|
|
|
-subj '/O=Nginx Proxy Manager/OU=Dummy Certificate/CN=localhost' \
|
|
|
|
-keyout /data/nginx/dummykey.pem \
|
|
|
|
-out /data/nginx/dummycert.pem
|
2018-11-05 10:58:22 +11:00
|
|
|
echo "Complete"
|
2018-11-02 10:06:37 -04:00
|
|
|
fi
|
|
|
|
|
2018-10-19 16:24:44 +10:00
|
|
|
# Run
|
2018-08-02 19:48:47 +10:00
|
|
|
exec nginx
|