mirror of
https://git.myvelabs.com/lab/nginx.git
synced 2025-12-17 21:26:13 +00:00
First commit
This commit is contained in:
commit
2a57f40199
3 changed files with 88 additions and 0 deletions
43
nginx.sh
Normal file
43
nginx.sh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/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
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue