apt-get update & apt-get upgrade
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update & apt-get upgrade
sudo apt-get install docker-ce docker-ce-cli containerd.io apache2-utils
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo dpkg -r --force-depends golang-docker-credential-helpers
sudo systemctl start docker / sudo systemctl stop docker
sudo systemctl enable docker
docker restart $(docker ps -q)
https://github.com/oliguo/Docker-Traefik-Lampp
cp -r ./Docker-Traefik-Lampp /opt/docker
mkdir -pv /opt/docker/portainer/data
docker run -d -p 9000:9000 \
--name portainer \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /opt/docker/portainer/data:/data \
portainer/portainer
Access the portainer by http://ip-adress:9000
sudo apt-get install proftpd proftpd-basic
sudo systemctl start proftpd.service / sudo systemctl stop proftpd.service
sudo systemctl enable proftpd.service
sudo nano /etc/proftpd/proftpd.conf
#
# Some logging formats
#
LogFormat default "%h %l %u %t \"%r\" %s %b"
LogFormat auth "%v [%P] %h %t \"%r\" %s"
LogFormat write "%h %l %u %t \"%r\" %s %b"
# You need to enable mod_logio.c to use %I and %O
LogFormat combinedio-more "%v %h %l %u %t \"%r\" %s %I %O"
# Logging
#
# file/dir access
#
ExtendedLog /var/log/proftpd/access.log WRITE,READ combinedio-more
#
#
# Record all logins
#
ExtendedLog /var/log/proftpd/auth.log AUTH auth
sudo mkdir -pv /opt/docker/apps
sudo mv /opt/docker/alpine-apache-php5 /opt/docker/apps/abc.com
or
sudo mv /opt/docker/alpine-apache-php7 /opt/docker/apps/abc.com
sudo groupadd abc_com_group
sudo useradd -d /opt/docker/apps/abc.com/www -g abc_com_group -s /sbin/nologin abc_com
sudo chown -Rv abc_com:abc_com_group /opt/docker/apps/abc.com/www
cat /etc/passwd | grep 'abc_com*'
sudo ftpasswd --passwd --file=/usr/local/proftpd/ftpd.passwd --name=abc_com --uid=1000 --gid=1000 --home=/opt/docker/apps/abc.com/www --shell=/sbin/nologin
sudo vim /etc/proftpd/conf.d/settings.conf
DefaultRoot /opt/docker/apps/abc.com/www abc_com_group
<Directory "/opt/docker/apps/abc.com/www">
<Limit CWD MKD RNFR READ WRITE STOR RETR>
DenyAll
</Limit>
<Limit CWD MKD RNFR READ WRITE STOR RETR>
AllowUser abc_com
</Limit>
</Directory>
sudo systemctl restart proftpd.service
docker network create web
cd /opt/docker/abc.com
docker build -t alpine-apache-php5 .
or
docker build -t alpine-apache-php7 .
#traefik v1 version
/opt/docker/docker-compose.yml
Or
#traefik v2.6 version
/opt/docker/docker-compose.traefik2.yml
defaultEntryPoints = ["https","http"]
debug = false
logLevel = "INFO"
[traefikLog]
filePath = "/opt/traefik/log/traefik.log"
format = "json"
[accessLog]
filePath = "/opt/traefik/log/access.log"
format = "json"
[file]
directory = "/opt/traefik/rules/"
watch = true
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[[entryPoints.https.tls.certificates]]
CertFile = "/opt/traefik/certs/*.abc.com/fullchain.pem"
KeyFile = "/opt/traefik/certs/*.abc.com/privkey.pem"
[entryPoints.traefik]
address = ":8080"
[entryPoints.traefik.auth]
[entryPoints.traefik.auth.basic]
users = ["admin:hash_password"]
[acme]
email = "[email protected]"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[docker]
endpoint = "unix:///var/run/docker.sock"
watch = true
echo $(htpasswd -nb admin 123456)
[entryPoints.traefik.auth]
[entryPoints.traefik.auth.basic]
users = ["admin:xxxx"]
[backends]
[backends.abc001]
[backends.abc001.servers.server1]
url = "http://123.123.123.123:10001"
[backends.abc002]
[backends.abc002.servers.server1]
url = "http://123.123.123.123:10002" #point to https part
[frontends]
[frontends.abc001]
backend = "abc001"
passHostHeader = true
[frontends.abc001.routes.route1]
rule = "Host:abc001.abc.com"
[frontends.abc002]
backend = "abc002"
passHostHeader = true
[frontends.abc002.routes.route1]
rule = "Host:abc002.abc.com"
sudo chmod 600 /opt/docker/traefik/acme.json
cd /opt/docker
docker-compose --compatibility up -d --force-recreate
providers:
docker: {}
log:
filePath: "/opt/traefik/logs/traefik.log"
format: json
level: INFO
# Configuring a buffer of 100 lines
accessLog:
filePath: "/opt/traefik/logs/access.log"
format: json
bufferingSize: 100
api:
# Dashboard
#
# Optional
# Default: true
#
dashboard: true
#insecure: true
entryPoints:
web:
address: ":80"
#http:
# redirections:
# entryPoint:
# to: websecure
# scheme: https
websecure:
address: ":443"
certificatesResolvers:
webResolver:
acme:
email: [email protected]
storage: /letsencrypt/acme.json
httpChallenge:
# used during the challenge
entryPoint: web
echo $(htpasswd -nb admin 123456)
- "traefik.http.middlewares.traefik2_auth.basicauth.users=admin:xxx"
cd /opt/docker
docker-compose -f docker-compose.traefik2.yml --compatibility up -d --force-recreate
SET PASSWORD FOR 'root' = PASSWORD('your password');
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password';
crontab -e
##clear traefik log and restart traefik
0 0 * * 0 rm /where is path/traefik/log/*
5 0 * * 0 docker restart traefik
##logging the stats per 30mins
*/30 * * * * docker stats -a --no-stream >> /log folder you created/docker-stats-log/`date +\%Y\%m\%d\%H\%M\%S`.csv
*/30 * * * * ps auxf > /log folder you created/htop-log/`date +\%Y\%m\%d\%H\%M\%S`.csv
##clear log every sunday
0 0 * * 0 rm /log folder you created/docker-stats-log/`date +\%Y\%m`*.csv
0 0 * * 0 rm /log folder you created/htop-log/`date +\%Y\%m`*.csv
##clear access log last month
59 23 1 * * * rm /opt/docker/abc.com/log/apache2/access_log.`date --date="$(date +\%m) -1 month" +\%Y-\%m*`
59 23 1 * * * rm /opt/docker/abc.com/log/apache2/ssl_access_log.`date --date="$(date +\%m) -1 month" +\%Y-\%m*`