Deploying PO Box on a Linux VM
Overview
Zilla PO Box is a container that simplifies integration with on-prem applications by extending into customer environments and making outbound API calls to push user and account information to Zilla. The shell script pobox_main.sh
is used to manage and deploy containers for PO Box using either Podman or Docker.
This article is designed as a playbook for completing prerequisite activities, configuring and deploying the PO Box container, and setting up a cron job to restart the container with the latest released image on a daily basis.
This article covers the following topics:
Prerequisites
Machine Specs
2vCPU
4GB RAM
25GB Disk
Libraries
Either Podman or Docker is installed to run the container
Get started and install Docker
If necessary, refer to this post for additional guidance on setting up Docker
jq is installed to parse the JSON response
curl is installed to make the necessary API calls
PO Box Directory
PO Box directory structure has been created identical to the structure below
pobox/
├── pobox-config/
└── pobox-output/
The
Zilla_API_Key
file has been saved under thepobox-config
directory for authenticating and managing deploymentsTo get the value for
Zilla_API_Key
via a secure credentials link, please reach out to the Zilla Customer Success Team
Whitelist URLs
Customers may need to whitelist certain URLs to successfully deploy PO Box. This list includes but is not limited to:
Zilla Application URL
US East Service endpoints and Docker endpoints
Configuring and Deploying PO Box
Configuring pobox_main.sh
Download the tar file on the target VM.
Before running the script, edit the
pobox_main.sh
script and set the values for the variables listed below.
ZILLA_URL
: This is the host URL of the Zilla server based on your tenant; Zilla has different host URLs for different tenants including:TENANT_DOMAIN
: This is the domain of your tenant. To find your tenant domain, clickSettings
in the Zilla app and find theYour Domains
section. Your tenant domain is the first domain listed under that section.POBOX_BASEDIR
: This is the absolute path to thepobox
directory, as outlined in the PO Box Directory section above.CONTAINER_TOOL
: This is the container tool used (eitherPodman
orDocker
).
Modify the
pobox_main.sh
file and modify theZILLA_URL
,TENANT_DOMAIN
,POBOX_BASEDIR
, andCONTAINER_TOOL
variables according to your environment.
Deploying PO Box
Run the command below to extract the
pobox-deployment.tar
file.
tar -xvf pobox-deployment.tar
Open the
pobox-deployment
directory. You will see thepobox_main.sh
,pobox_pull_image.sh
, andpobox_launch.sh
shell script files.Run the command below to deploy the PO Box container.
bash pobox_main.sh
After running the pobox_main.sh
script, an output similar to the below example will display. You will be prompted to indicate whether you want to proceed by entering either yes
or no
.
After confirming the configured values are correct, proceed by entering
yes
. If the values are incorrect, enterno
and refer to the Configuring pobox_main.sh section above for instructions to update the values as needed.
TENANT_DOMAIN: tenant-domain.com
POBOX_BASEDIR: /absolute/directory/path/of/pobox
ZILLA_URL: https://app.zillasecurity.com
CONTAINER_TOOL: podman
Please review the above values. Do you want to proceed? (yes/no):
Once the PO Box deployment is complete, run one of the two commands below based on whether Podman or Docker was used to validate that it was deployed correctly.
For Podman installs, run the command below at the Linux $ prompt.
podman ps
For Docker installs, run the command below at the Linux $ prompt.
docker ps
If successful, the output will look similar to the below and and will show a running container with a name similar to 508384223771.dkr.ecr.us-east-1.amazonaws.com/zinc:latest
.
ubuntu@ip-172-26-13-73:~/pobox/pobox-deployment$ podman ps
ID IMAGE COMMAND CREATED STATUS PORTS NAMES
508384223771.dkr.ecr.us-east-1.amazonaws.com/zinc:latest node app/dist/src... 7 minutes ago Up 7 minutes ago zilla_pobox
Scheduling a cron Job
The next step is to set the POBox deployment as a daily cron job, which is required to restart the container with the latest released image that will be pulled-down from the container registry at http://508384223771.dkr.ecr.us-east-1.amazonaws.com/
.
Once the cron job has been set, the shell script pobox_main.sh
will initialize the config variable and execute two tasks daily:
pobox_pull_image.sh
to pull the latest PO Box imagepobox_launch.sh
to run/restart the PO Box container
Run the command below to open the crontab. If you are prompted to select a crontab editor, enter
nano
.
crontab -e
In the crontab editor, run the command below replacing the
/absolute/directory/path/of/pobox-deployment
directory path with correct value.
In the example below, the script will be executed daily at 01:00 AM UTC.
0 1 * * * cd /absolute/directory/path/of/pobox-deployment && echo "yes" | bash pobox_main.sh
Troubleshooting
Access Denied Error for Zilla_API_Key
In order to run the PO Box container, the user inside the container needs to be able to access the Zilla_API_Key
file. If the owner of the mounted directory is not the same as the container’s user, the container exits with an access denied error for the Zilla_API_Key
file.
pobox/
├── pobox-config/
├──Zilla_API-Key
└── pobox-output/
Docker Solution
When working with Docker the User-Namespace-Mapping is disabled by default. The UID-GID (user ID and group ID) of the user inside the container and the UID-GID of the owner of the PO Box directory on the host machine must be the same.
Rootless Podman Solution
When working with Rootless Podman the User-Namespace-Mapping is strictly enabled. The owner on the PO Box directory must be updated to the mapped user inside the container.
SELinux Flag Solution
Z
: SELinux policies can restrict access based on labels, so theZ
flag helps to apply the correct label automatically to prevent access denials or potential security risks.U
: TheU
flag ensures that when a volume is mounted between the host and a container, the user and group IDs (UIDs and GIDs) inside the container are properly mapped to the corresponding UIDs and GIDs on the host system.