mirror of
https://git.myvelabs.com/lab/nginx.git
synced 2025-12-17 21:26:13 +00:00
43 lines
946 B
Bash
43 lines
946 B
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
|
||
|
|
# Fill in the following variables
|
||
|
|
appname=
|
||
|
|
url=
|
||
|
|
domain=
|
||
|
|
port=
|
||
|
|
eff_email_address=
|
||
|
|
|
||
|
|
# .conf installation
|
||
|
|
{
|
||
|
|
|
||
|
|
# Exit if variables are null
|
||
|
|
if [ -z ${appname} ] || [ -z ${url} ] || [ -z ${domain} ] || [ -z ${port} ] || [ -z ${eff_email_address} ]
|
||
|
|
then
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
sudo tee /etc/nginx/sites-available/${appname}.conf >/dev/null <<conf
|
||
|
|
server {
|
||
|
|
server_name ${url};
|
||
|
|
include local/http_upgrade;
|
||
|
|
|
||
|
|
location / {
|
||
|
|
proxy_pass http://${domain}:${port};
|
||
|
|
include local/proxy_params;
|
||
|
|
|
||
|
|
error_log /var/log/nginx/${appname}_error.log;
|
||
|
|
access_log /var/log/nginx/${appname}_access.log;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
conf
|
||
|
|
|
||
|
|
sudo ln -s -f /etc/nginx/sites-available/${appname}.conf /etc/nginx/sites-enabled/
|
||
|
|
|
||
|
|
if sudo nginx -t
|
||
|
|
then
|
||
|
|
sudo systemctl reload nginx.service
|
||
|
|
sudo certbot --nginx --non-interactive --agree-tos --no-eff-email -m ${eff_email_address} -d ${url} \
|
||
|
|
--staple-ocsp --hsts --no-redirect
|
||
|
|
fi
|
||
|
|
|
||
|
|
}
|