Bash (debian) script for setting up nginx with docker.
The script must be ran with root previliges.
The script needs a username specified using -u
option.
After the script is installed you can run it from any directory using sudo ndss
instead of sudo ./setup.sh
.
sudo ./setup.sh -u user -d example.com
sudo ./setup.sh -u user -t proxy -d example.com -s http://docker.host.ip:8080
sudo ./setup.sh -u user -t php -d example.com
Just append --ssl
to any of the previous commands to automatically request an SSL certificate
sudo ./setup.sh -u user -d example.com --ssl -m [email protected]
sudo ./setup.sh -u user -d example.com --enable/disable
sudo ./setup.sh -u user -d example.com --delete
sudo docker exec anismk-nginx-server nginx -s reload
sudo ./setup.sh -u user -l
To be able to run this script more easily without having to cd to this folder, run the following command.
sudo ./setup.sh -u user -i
This script will then be avaible by calling ndss
from the command line
sudo ./setup.sh -u user -b
sudo ./setup.sh -u user --update
sudo ./setup.sh -u user --shutdown
sudo ./setup.sh -u user --clean
argument | default | description |
---|---|---|
-u --user | - | the username of the owner of the nginx server |
-p --path | /home/$USERNAME/nginx-data | the path to the folder where all nginx files should be stored |
-d --domain | - | the domain of the server to be created/modified |
-t --type | 'server' | 'server': static files server / 'php': server for serving php files / 'proxy': nginx reverse proxy server |
-s --proxiedServer | - | the server to be proxied, used in combination with type 'proxy'. To access a server running on host use the IP "docker.host.ip" |
--ssl | - | automatically acquire an SSL certificate for the specified domain |
-m --email | - | the email to be used for SSL certificate renewal notifications |
--disable | - | disable the server for the specified domain |
--enable | - | enable an already disabled server for a domain |
--delete | - | delete the server for the specified domain and all its files |
-l --list | - | list all the configured servers. |
-b --backup | - | creates a gzipped tar file and saves it in the user's home directory |
-i --install | - | install this script to make it more accessible using ndss command |
--update | - | backup the old configuration and update the nginx base images |
--shutdown | - | shutsdown running containers |
--clean | - | shutsdown running containers and removes the built images. |
- update readme file (because it's way too fucking old)
- make it easier to add new server quickly
- add a way to specify the host IP as proxied ip address
- add the functionality to signal nginx to reload the data.
- add the functionality to start certbot and automatically request a let's encrypt certificate.
- add the functionality to disable/remove a server.
- add basic support for php-fpm and/or apache for serving php files.
- add a simple way to list all available servers and if they're active or not
- improve logging (because this [log] and [info] shit doesn't make sense)
- add systemd timer for checking certifcate renewals.
- make the script installable
- add option to easily make compressed backups
- add the functionality to easily update nginx to latest version.
- build release package and update instructions on how to install the script
- make it easier to add foreign container to the nginx network
- add a check to stop the script if one of the actions requires the container to be already running but it's not
- clean the directory structure