[5 Mins Docker] Deploy Azure Naming Tool into Koyeb for Free - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Sunday, December 17, 2023

[5 Mins Docker] Deploy Azure Naming Tool into Koyeb for Free

This post is to show you how to create a your own free public available website for Azure Naming Tool Github project using Koyeb's free service. 

It is simple, easy, fast and completely free. No credit card required. 


Web GUI:



Azure Naming Tool 

The Azure Naming Tool was created to help administrators define and manage their naming conventions, while providing a simple interface for users to generate a compliant name. The tool was developed using a naming pattern based on Microsoft's best practices. Once an administrator has defined the organizational components, users can use the tool to generate a name for the desired Azure resource.



Github : https://github.com/mspnp/AzureNamingTool

Docker Image : docker.io/tfisicaro/aznamingtool

Demo site: https://aznamingtool.51sec.org/




Steps


Koyeb is a developer-friendly serverless platform to deploy apps globally. No-ops, servers, and infrastructure management. For side-projects, it is $0/month. Free account ,Koyeb is giving you $5.5/month free credit to use, which is enough for two Nano type apps, or one Micro type app. 


Price list:

 

NANO

MICRO

SMALL

MEDIUM

LARGE

XLARGE

CPU

1

1

1

2

4

8

RAM

256MB

512MB

1GB

2GB

4GB

8GB

DISK

2.5GB SSD

5GB SSD

10GB SSD

20GB SSD

40GB SSD

80GB SSD

PRICE

$2.7/mo

$5.4/mo

$10.7/mo

$21.4/mo

$42.9/mo

$85.7/mo


If you have Github account, you can log in with your Github account for free. But you do need provide a valid credit card to enable your free account to use. 

After you created and enabled your free account, you should be able to log in and start your Koyeb journey. 

1. Create an app



2.  Choose Docker

Enter docker image: docker.io/tfisicaro/aznamingtool


3. Choose nano type instance since Sshwifty is a very light application


4. Change default port 8000 to 80 , also, change your app name to something you can remember easily



Port 80

5. Click Deploy button then wait about 5 minutes to let system fully loaded


Domain Setup 

 
Configure a custom domain on your Koyeb App:


After 5 minutes:




Cloudflare setup:




Testing in Play With Docker

 
https://labs.play-with-docker.com/


$ sudo docker run -d -p 8081:80 docker.io/tfisicaro/aznamingtool
Unable to find image 'tfisicaro/aznamingtool:latest' locally
latest: Pulling from tfisicaro/aznamingtool
b5a0d5c14ba9: Pull complete 
4ece0626219d: Pull complete 
ccb4ba5bb726: Pull complete 
bdf2c62d9548: Pull complete 
d2e769e5b08a: Pull complete 
9606d1336b28: Pull complete 
4f4fb700ef54: Pull complete 
1ace93df5d16: Pull complete 
Digest: sha256:48ac1f663de64423ab00fd882c097538992c9ab6fe5bd15bf24ece35c1c0ce80
Status: Downloaded newer image for tfisicaro/aznamingtool:latest
51a6ad7591a77fc20f57eeba31193ce95a54af61c6ccf58b8a6e823749534960
[node1] (local) [email protected] ~
$ 


Copy: Ctrl+Insert 
Paste: Ctrl+shif+v


Self Hosted Docker Installation Pre-requirements

Free resources you might need to complete this docker project:


Pre-installed services:

  • Docker, 
    • apt update
    • apt install docker.io
    • apt install docker-compose
    • apt upgrade docker.io
    • mkdir /root/data/docker_data/<docker_name>
  • Docker-Compose (Using Ubuntu OS for the commands)
    • Docker-compose down
    • Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
      • cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
    • docker-compose pull
    • docker-compose up -d
    • docker image prune
  • Portainer (Optional)
    • docker volume create portainer_data
    • docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
  • Install some applications: apt install wget curl sudo vim git (Optional)
  • aapanel with Nginx (Optional)
  • Nginx Proxy Manager (Optional)
  • Install screen (Optional)
    • Install screen (Depends on the Linux Distribution if it came pre installed or not) : yum install screen
    • Initiate a Screen : screen or  screen -S <screen name> <command to execute>
    • Detach from the screen : "CTRL+A,D" not "CTRL+A+D"
    • List all the screen currently working : screen -ls
    • Reattach to a screen : screen  -r  <session number> or screen -r <screen name>
    • Kill specific screen: screen -X -S <screen name> quit
    • Kill all screens : pkill screen

Monitoring Usage

  • Docker stats

Remove Docker and Related folders

  • docker stop <Docker Name> # stop the docker but not remove anything. 
  • docker rm -f <Docker Name>  # remove speficic container, but will not delete mapped volumes
  • rm -rf /root/data/docker_data/<Docker Mapped Volumns>  # remove all mapped volumes

Restrick Journal Log File Size:

  • journalctl --vacuum-size=100M
  • Limit it to 25M:
nano /etc/systemd/journald.conf
SystemMaxUse=25M
systemctl restart systemd-journald.service


or 
sudo bash -c 'echo "SystemMaxUse=100M" >> /etc/systemd/journald.conf'
sudo systemctl restart systemd-journald



Enable IPv6 and Limit Log File Size (Ubuntu)

Special command to cleans all logs and you don't need to stop the containers.

  • sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'
Add customized self defined IPv6 address segment to enable container's IPv6 fucntion. And limit log file's size and numbers in case log file to fill all hard drive's space. 

cat > /etc/docker/daemon.json << EOF
{
    "log-driver": "json-file",
    "log-opts": {
        "max-size": "20m",
        "max-file": "3"
    },
    "ipv6": true,
    "fixed-cidr-v6": "fd00:dead:beef:c0::/80",
    "eixperimental":true,
    "ip6tables":true
}
EOF

Restart Docker service:

systemctl restart docker

Limit number of log files:

cat /etc/logrotate.d/rsyslog
/var/log/syslog
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
    rotate 4
    weekly
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        /usr/lib/rsyslog/rsyslog-rotate
    endscript
}

You can change 4 to some other value, such as 1, so that only one file is stored.




Videos

 








References




No comments:

Post a Comment