Why I Finish the Environment File Before Turning Protection On

●2 ●52 ●174
calendar_today • schedule8 min read

I do not turn SafeLine protection on the moment the containers start. Protection, in the sense that matters to an application, begins when traffic is sent through the WAF and an application is added in the console. Before that cutover I want a written decision on every environment variable the manual deploy expects. A half-filled .env file is not a minor cleanup task. It is the file that sets the install directory, the image tag, the console port, the database password, the internal network prefix, and the secrets the detector and management services share.

SafeLine is a self-hosted web application firewall. The introduction describes it as a reverse proxy placed in front of a web application. Clients pass through that proxy before they reach the origin. It filters and monitors HTTP and HTTPS traffic and is documented to block malicious requests such as SQL injection, XSS, code injection, OS command injection, CRLF injection, LDAP injection, XPath injection, RCE, XXE, SSRF, path traversal, backdoor, brute force, HTTP flood, and bot abuse. The same introduction lists core capabilities that include defenses for web attacks, proactive bot-abuse defense, HTML and JavaScript code encryption, IP-based rate limiting, and a web access control list. Feature notes also describe rate limiting, CAPTCHA challenge, authentication challenge, and dynamic protection for HTML and JavaScript. Those controls are only useful after the proxy path is correct, so I treat the environment file as the last gate before I point a domain at the WAF. Source: https://docs.waf.chaitin.com/en/home

The decision I make before any traffic moves

The application guide says SafeLine is developed based on nginx. It receives traffic for the original site, cleans malicious attack traffic, and forwards the remaining traffic to the upstream application. Adding an application in the console requires a domain, hostname, or IP, a listen port such as 80 or 443, and the real upstream address. For HTTPS applications the SSL option must be checked. After those fields are saved, the domain has to resolve to the SafeLine server. That DNS change is the moment protection becomes real for users. I will not make it until the manual deploy variables are decided, written, and permission-locked. Source: https://docs.waf.chaitin.com/en/GetStarted/AddApplication

Manual deploy is documented separately from the automatic installer. It expects Docker, a directory with at least 5 GB free, a downloaded compose file, and a .env file that you write yourself. Source: https://docs.waf.chaitin.com/en/GetStarted/Deploy

Checklist before I write the file

I run the host checks from the deploy guide before I choose any value. The documented minimums are Linux, x86_64 or arm64, Docker 20.10.14 or above, Docker Compose 2.0.0 or above, one CPU core, 1 GB of memory, 5 GB of disk, and a CPU with the ssse3 instruction. The same page lists the commands I actually run: uname -m, docker version, docker compose version, a processor listing from /proc/cpuinfo, free -h, df -h, and lscpu piped to a search for ssse3. If any of those checks fail, I stop. I do not plan to turn protection on against an undersized or unsupported host and fix the platform later.

Then I decide the variables in the official template, not a shortened list of my own.

Directory and image choices come first. SAFELINE_DIR is the directory SafeLine uses for configuration and data. The guide creates /data/safeline and requires at least 5 GB there. IMAGE_TAG is the SafeLine version to be used. I keep latest only when I have already accepted that channel. IMAGE_PREFIX is the mirror repository prefix. The template sets it to chaitin, and I keep that published value rather than inventing another registry path.

The release channel is a separate decision. Setting RELEASE=-lts selects the LTS images. The deploy page states that the LTS version will no longer be maintained starting from 9.1.0-LTS on 14 August 2025, and that LTS users are strongly recommended to upgrade to the latest version. If concerns remain, the same note recommends upgrading one month after a new version is released. An empty RELEASE is also a decision: it means I am not selecting the LTS suffix. I write that choice down before I touch the file.

Architecture is not optional on ARM. For an ARM server the guide says to set ARCH_SUFFIX=-arm and to set POSTGRES_IMAGE to chaitin/safeline-postgres-arm:15.18. On the default template, ARCH_SUFFIX is empty and POSTGRES_IMAGE is chaitin/safeline-postgres:15.18. The same section states that SafeLine installed on ARM requires a Pro license to work properly, and that the Personal Edition is not supported on ARM. If I cannot accept that boundary, I do not continue an ARM manual deploy, and I do not swap in the non-ARM image names to avoid the decision.

Network and console choices are next. MGT_PORT is the web console port. The template and the later UI step both use 9443, and the console URL is https:// followed by the SafeLine IP, port 9443, and a trailing slash. I change that port only after I have checked that the host can spare it, and I record the chosen port in the access plan before launch. SUBNET_PREFIX is the internal network communication address prefix. The template uses 172.22.222. I compare that prefix with existing Docker and host networks before I keep it. MGT_PROXY is the number of console proxy layers. The guide says it should be used only when configuring a proxy for the console, and that the default of 0 means no proxy is configured. I leave it at 0 unless that console-proxy case is actually mine. The template also includes REGION=-g. The variable glossary on the same page does not define REGION, so I keep the documented example instead of guessing another region code.

Secrets are generated, not typed from memory. The guide shows three commands run from the SafeLine directory. DETECTOR_MGMT_TOKEN and MGT_INTERNAL_TOKEN each come from 32 random bytes printed as hexadecimal, which matches the template note of a 64-character hex value. DETECTOR_AES_KEY is 16 alphanumeric characters drawn from /dev/urandom. POSTGRES_PASSWORD is the Postgres database initialization password, so I replace the placeholder before the first start. The template also sets DETECTOR_MGMT_AUTH=on and DETECTOR_UPDATE_VERIFY=on, and it leaves DETECTOR_UPDATE_PUBLIC_KEY empty. I copy those lines as published. I do not fill the public-key field with a value the deploy page does not specify. A small set_env helper in the same section updates an existing key or appends it, which is how I avoid leaving a placeholder beside a generated value.

How I commit the file without turning protection on

After the decisions are written down, I create /data/safeline, download the compose file into that directory, and write .env. I then set the file mode to 600. The later directory steps also create the runtime path, set the runtime, management, socket, and Postgres data directories to mode 700, set .env to mode 600 again, and link the runtime socket file to /var/run/safeline.sock. Those permission steps are part of the checklist, not optional cleanup after the first request.

Only then do I run docker compose up -d. The guide says this can take several minutes. A running stack is still not protection. I open the console on the port I chose, run docker exec safeline-mgt resetadmin, and store the initial admin username and password that command prints. I log in and confirm the console is the one I intended. I still do not add an application, and I do not change DNS, until every checklist item above is marked done. Adding the application, resolving the domain to the SafeLine host, and sending traffic are the steps that place the reverse proxy in the user path. That is the turn-on I am trying not to rush.

What I refuse to skip

I keep the checklist short enough to finish on the day of the deploy, and strict enough that a missing secret or an undecided ARM license stops the work. The answers I want in writing are the architecture and image names, the release channel, the directory and disk budget, the console port and proxy-layer count, the subnet prefix, and the generated secrets with their file mode. If one answer is that the team will fix it after go-live, I do not add the application.

Why do I separate container start from turning protection on?

Container start only brings up the SafeLine services described in the deploy guide. Protection for a site starts when I add an application and resolve its domain to the SafeLine server, as the application guide describes. I want the environment file finished before that DNS and upstream cutover, because a wrong port, subnet, architecture suffix, or secret is much harder to explain once users are already flowing through the proxy.

Which variables do I refuse to leave as placeholders?

I replace the Postgres password, the detector management token, the management internal token, and the detector AES key before the first docker compose up -d. The deploy page shows those as generated or chosen values, not as text to leave in the file. I also decide ARCH_SUFFIX, POSTGRES_IMAGE, and RELEASE explicitly, including the decision to leave RELEASE empty when I am not selecting LTS.

What host facts can block the whole checklist?

The deploy requirements can block the work before any variable is written. I need Linux on x86_64 or arm64, Docker 20.10.14 or newer, Docker Compose 2.0.0 or newer, at least one core, 1 GB of memory, 5 GB of disk, and ssse3. On ARM I also need to accept that a Pro license is required and that the Personal Edition is not supported. If those facts are not true, I do not continue to the console or to an application entry.

Should I change MGT_PROXY or REGION while preparing the file?

I set MGT_PROXY to 0 unless I am actually configuring proxy layers for the console, which is the only case the deploy guide describes. I keep REGION=-g because that is the value in the published template, and the variable list does not give me another documented choice. Guessing either value is not part of preparing the file.

What do I do with the admin password relative to this checklist?

After compose is up, docker exec safeline-mgt resetadmin prints the initial username and password. I treat that output as a secret to store before anyone else uses the console. It is not a substitute for the .env secrets. Both have to be known and restricted before I add an application and call the site protected.


SafeLine has surpassed 700,000 installations worldwide as of September 30, 2026. SafeLine Pro annual promotional pricing is $650-$880, compared with the regular $1,000 per year.

Want more #waf & #docker deep dives?

Join 5,992+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

Delivering Database Changes

Steve Fentonverified - Jul 22

Why I Change the WAF Web Console Listening Port Before Turning Protection On

Lia - Oct 30

How to Prepare WAF Environment Variables for a Manual Deploy

Muzilla - Nov 1

Why I Check Rule Evidence Before Turning WAF Protection On

Lia - Nov 10

Why I Check the Investigation Path Before Turning WAF Protection On

Lia - Nov 9
chevron_left
3.3k Points • 228 Badges
138Posts
0Comments
1Connections
Homelab operator. Security tools. Self-hosted everything. Open source.

Related Jobs

Commenters (This Week)

4 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!