MR2K SOLUTIONS • DEVOPS OPERATIONS

RFB, Infrastructure & Deployment Guide

Daily Ready-for-Business checks, service inventory, infrastructure flow, authorizer/API protection, deployment, Nginx, SSL, logs and safe maintenance.
v2.1DEV + PRODDockerNginxPostgreSQL / MongoDBJWT Authorizer

1. Purpose & RFB Rules

The Daily RFB process makes the morning operational state visible and testable even when the primary DevOps engineer is unavailable. The flow covers server access/resource health, Docker, domain/Nginx/HTTPS, PostgreSQL/MongoDB, application/API smoke testing, logs, controlled cleanup and written handover.

GREEN / PASS
Critical services healthy and business smoke test passes. Business can proceed.
AMBER / WARN
Non-critical degradation, expected maintenance or incomplete test. Record and notify owner.
RED / FAIL
Critical application, database, network, TLS, Docker or domain path unavailable. Escalate immediately.
Core rule: RFB is a health/readiness check first. Do not turn routine morning checks into unapproved production changes.

2. Service Inventory

The service inventory is the source of truth for expected domains, containers, ports, database dependencies, owners and criticality. Always compare the live server with the approved inventory before declaring RFB complete.

Production Service InventoryGoogle Drive spreadsheet — production domain/container/service mapping. Development Service InventoryGoogle Drive spreadsheet — development domain/container/service mapping.
Required inventory fieldsWhy
Domain / HTTPS URLExternal reachability and TLS validation.
Reverse-proxy path / upstream host:portConfirms Nginx routing.
Docker container + image/tagConfirms deployed service/version.
Database dependencyHelps trace application failures.
Criticality + ownerDetermines escalation and RFB impact.

3. Infrastructure Flow

Typical MR2K public-service flow: the client reaches the domain, DNS points to the server/load-balancer entry point, Nginx terminates HTTPS and routes traffic to the correct Docker service, and the application communicates with its approved database.

ClientBrowser / APIDNS / DomainA / proxy recordNginxTLS + routingDocker ServicesApp / API containersHost port → container porthealth / logs / restartDatabasePostgreSQL / MongoDB
Exact domains, ports, containers and database relationships must come from the approved Dev/Prod inventory; this diagram describes the operational pattern.

4. Authorizer & API Protection

Protected API requests use token-based verification. The reverse proxy/gateway sends the request through the authorization validation path before the protected API is allowed to continue. The authorizer should validate the approved token/JWT according to the application's configured rules, such as signature, expiry and required claims.

ClientBearer tokenNginx / Gatewayauth validation pathAuthorizerverify tokensignature / expiry / claimsProtected APIDocker applicationInvalid / missing token → reject (normally 401/403)
Operational check: For a protected endpoint, verify both an approved valid-token request and an invalid/missing-token request. Never put real JWTs, API keys or credentials into this document, screenshots, tickets or chat.

5. Daily RFB Checklist

Run the checks in this order. Commands below are intentionally mostly read-only. Replace placeholders with values from the approved service inventory.

#AreaMinimum checkPASS / concern
1Server identityhostnamectl --static, whoami, uptimeCorrect server/operator and normal uptime/load.
2Resourcesfree -h, nproc, df -hT, df -ihNo severe memory/CPU pressure or filesystem/inode exhaustion; investigate >80–85% capacity.
3System servicessudo systemctl --failedNo unexpected failed critical services.
4Dockersudo systemctl is-active docker, docker infoDocker active and responding.
5Containersdocker ps -aExpected critical containers Up; no restart loops/unexpected exits/unhealthy services.
6Port mappingdocker ps --format ..., sudo ss -lntpHost/container ports match approved inventory; no unexpected public listener.
7Nginxsudo systemctl is-active nginx, sudo nginx -tActive and configuration test successful.
8DNS/HTTPSgetent hosts <domain>, curl -I https://<domain>/Resolves correctly; expected HTTP status and valid TLS.
9PostgreSQLpg_isready plus read-only DB checksAccepting connections; no unusual sessions, growth, blocking or autovacuum concerns.
10MongoDBmongosh ... pingPing succeeds if MongoDB is used.
11LogsDocker/Nginx/system/PostgreSQL/Mongo logsNo unexplained fatal errors, restart loops, upstream failures or OOM events.
12Application/APIHTTPS health endpoint + approved smoke testCritical business flow works; protected API accepts valid token and rejects invalid/missing token.
13Capacitydocker system df, journalctl --disk-usageStorage growth understood; no blind cleanup.
14HandoverRecord status, evidence, ticket/ownerGREEN / AMBER / RED communicated.

6. Daily RFB Commands

6.1 Server baseline

# Identity, uptime, memory and filesystem
hostnamectl --static
whoami
uptime
free -h
nproc
df -hT
df -ih
cat /etc/os-release

# Failed services
sudo systemctl --failed

# Optional combined baseline
hostnamectl --static && uptime && free -h && df -hT
Resource rule: Capacity above roughly 80–85% is an investigation trigger, not an automatic delete/cleanup instruction.

6.2 Docker health

# Docker daemon
sudo systemctl is-active docker
docker info

# All containers: name, image, status and ports
docker ps -a --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'

# Running containers
docker ps

# Restart loops / exited containers
docker ps -a --filter status=restarting
docker ps -a --filter status=exited

# Health status where healthchecks exist
docker ps --format 'table {{.Names}}\t{{.Status}}'

# Networks and images
docker network ls
docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.CreatedSince}}'

# Docker disk usage
docker system df
RFB rule: A critical container that is Exited, continuously Restarting or Unhealthy is at least AMBER and normally RED if the related business function is unavailable.

6.3 Ports, Nginx and domain routing

# Listening ports
sudo ss -lntp

# Nginx state and syntax
sudo systemctl is-active nginx
sudo nginx -t

# Enabled sites
ls -la /etc/nginx/sites-enabled/

# DNS resolution
getent hosts <domain>

# HTTPS status and remote IP
curl -sS -o /dev/null -w 'HTTP=%{http_code} REMOTE_IP=%{remote_ip}\n' https://<domain>/

# Headers only
curl -I https://<domain>/

6.4 PostgreSQL daily commands

# Service / readiness
sudo systemctl is-active postgresql
psql --version
pg_isready

# Databases
sudo -u postgres psql -c '\l'

# Database sizes
sudo -u postgres psql -c "SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database WHERE datistemplate=false ORDER BY pg_database_size(datname) DESC;"

# Sessions by database/user/state
sudo -u postgres psql -c "SELECT datname, usename, state, count(*) FROM pg_stat_activity GROUP BY datname, usename, state ORDER BY count(*) DESC;"

# Long-running active queries (>10 minutes)
sudo -u postgres psql -c "SELECT pid, datname, usename, now()-query_start AS duration, state, left(query,120) FROM pg_stat_activity WHERE query_start IS NOT NULL AND now()-query_start > interval '10 minutes' AND state <> 'idle' ORDER BY query_start;"

# Dead tuples / autovacuum / analyze
sudo -u postgres psql -c "SELECT schemaname, relname, n_live_tup, n_dead_tup, last_autovacuum, last_autoanalyze FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 20;"

# Replication, only if applicable
sudo -u postgres psql -c 'SELECT * FROM pg_stat_replication;'

# PostgreSQL storage
sudo du -sh /var/lib/postgresql /var/log/postgresql 2>/dev/null

# Recent PostgreSQL errors
sudo journalctl -u postgresql --since 'today' --no-pager | tail -n 100
Do not do during normal RFB: DELETE business data, DROP databases/tables, TRUNCATE tables, terminate sessions, manually remove WAL/data files, or change PostgreSQL settings unless an approved incident/change procedure authorizes it.

6.5 MongoDB daily commands

# Host-installed MongoDB, if applicable
sudo systemctl is-active mongod
mongosh --version

# Safe connectivity test
mongosh --quiet --eval 'db.adminCommand({ ping: 1 })'

# Server status check
mongosh --quiet --eval 'db.serverStatus().ok'

# Recent errors
sudo journalctl -u mongod --since 'today' --no-pager | tail -n 100

If the service is named differently, use the approved unit name from the service inventory. If MongoDB is containerized, use the Docker/container healthcheck instead of assuming a host service.

6.6 Logs and incident indicators

# Recent container log sample
docker logs --tail 200 <container>

# Container activity during the last 30 minutes
docker events --since 30m --until 0s

# Nginx errors
sudo tail -n 200 /var/log/nginx/error.log

# System errors since today
sudo journalctl --since 'today' -p err..alert --no-pager

# OOM indicators
sudo dmesg -T | grep -i -E 'oom|out of memory' | tail -n 50

Look for repeated ERROR/FATAL messages, database connection failures, upstream timeout/refused errors, 5xx responses, unexpected container restarts and OOM events.

7. PostgreSQL Health & Maintenance Readiness

CheckExpectedAction
Service/readinessActive; pg_isready accepting connections.Investigate service/startup/connectivity failures.
Database list/sizeExpected databases present; no unexplained rapid growth.Record unusual growth; involve DB owner.
SessionsNo unexpected surge/excessive connections.Investigate before any termination.
Long queriesNormally no unexplained active query >10 minutes.Report; do not terminate without authorization.
Dead tuples/autovacuumNo concerning stale autovacuum/analyze state.Record maintenance candidates.
BlockingNo unexplained blocking of critical application queries.Investigate with application/DB owner.
ReplicationExpected replicas connected, if applicable.Investigate lag/disconnects.
Storage/logsWithin approved capacity.Use approved retention/maintenance procedure.
Maintenance principle: RFB is primarily a health check. Cleanup, vacuum changes, session termination, data deletion and retention changes are maintenance/change activities unless explicitly authorized.

8. MongoDB Health

For MongoDB services, validate service state, client version, ping/server status and recent logs. The normal RFB action is read-only validation. Cleanup or data modification requires the approved maintenance/change process.

9. Logs & Incident Indicators

IndicatorCommandEscalation trigger
Container logsdocker logs --tail 200 <container>Repeated ERROR/FATAL, startup failure, DB connection failure.
Container eventsdocker events --since 30m --until 0sUnexpected restart/stop activity.
Nginx errorssudo tail -n 200 /var/log/nginx/error.logRepeated upstream timeout/refused/5xx.
System journalsudo journalctl --since 'today' -p err..alert --no-pagerNew critical system errors.
Diskdf -hTCritical filesystem near capacity.
Memory/OOMfree -h and dmesg checkOOM events or severe memory pressure.

10. Application / API Full-Flow Smoke Test

The goal is not to execute every test case. Prove the complete business path from internet entry point through reverse proxy, container, application and database.

  1. Open the primary application domain and confirm the login page loads.
  2. Confirm HTTPS certificate is valid and there is no browser security warning.
  3. Use an approved non-production/test account where available; never store passwords here.
  4. Confirm authentication succeeds and the dashboard/landing page loads.
  5. Open one core business screen and verify data can be read.
  6. Execute one safe read-only or reversible business action.
  7. Check browser/network requests for unexpected repeated 401/403/404/5xx responses.
  8. Verify a core database-backed read succeeds.
  9. If event/history/notification features exist, open one representative record.
  10. Logout and confirm the session is invalidated as expected.
  11. Record the exact function/endpoint tested and result.

HTTP/API checks

curl -I https://<domain>/
curl -sS -o /dev/null -w 'HTTP=%{http_code} TIME=%{time_total}\n' https://<domain>/health
curl -sS https://<domain>/health
curl -vk --max-time 15 https://<domain>/api/<safe-read-only-endpoint>

Do not use -k for the normal PASS test. It disables certificate verification and should only be used for troubleshooting.

Protected API token check

# Approved test token only
curl -sS -o /dev/null -w 'HTTP=%{http_code} TIME=%{time_total}\n' \
  -H 'Authorization: Bearer <APPROVED_TEST_TOKEN>' \
  https://<domain>/api/<protected-endpoint>

# Missing/invalid token should be rejected according to application policy
curl -sS -o /dev/null -w 'HTTP=%{http_code}\n' \
  https://<domain>/api/<protected-endpoint>

11. Capacity & Controlled Cleanup

First inspect. Then confirm authorization for any change. Do not use broad destructive cleanup simply to make the server look clean.

AreaInspectCleanup rule
Disk / inodesdf -hT, df -ihLocate consumers before deletion.
Filesystem usagesudo du -xhd1 / 2>/dev/null | sort -hDelete only approved application/temp data.
Docker diskdocker system dfDo not routinely run broad prune commands; retain rollback images as required.
Stopped containersdocker ps -a --filter status=exitedRemove only verified obsolete containers.
Nginx logssudo du -sh /var/log/nginxUse logrotate/approved retention, not manual active-log deletion.
Journalsudo journalctl --disk-usageUse approved journal retention policy.
APT cachesudo du -sh /var/cache/apt 2>/dev/nullPackage-manager cleanup only when approved.
Temporary filessudo du -sh /tmp /var/tmp 2>/dev/nullDelete only known-safe stale temporary files.
Production rule: If a cleanup command deletes, prunes, vacuums, terminates, rotates or modifies anything, treat it as a maintenance/change action and record what changed, why, who authorized it and the post-change verification.

12. Deployment Guide — Container to Public Service

  1. Confirm image/tag. Pull the approved image from the registry and confirm the intended version.
  2. Run the container. Publish only the required host port; inject approved environment/secrets through the normal secure method.
  3. Check container locally. Confirm it is Up and the application responds on its container port through the host mapping.
  4. Record the mapping. Update the service inventory with container name, image/tag, host port, container port, domain, owner and criticality.
  5. Point DNS. Create/update the approved DNS record to the public entry point.
  6. Configure Nginx. Add the domain server block and proxy the domain to the approved local host port.
  7. Validate Nginx. Run sudo nginx -t; reload only after a successful test.
  8. Test HTTP/HTTPS. Verify DNS, routing, application response and logs.
  9. Add SSL. Use Certbot for the approved domain and verify renewal readiness.
  10. Run RFB smoke test. Validate health endpoint, authentication, protected API and a core business flow.

Example container start

docker pull <registry>/<image>:<tag>
docker run -d \
  --name <container-name> \
  -p <HOST_PORT>:<CONTAINER_PORT> \
  --restart unless-stopped \
  <registry>/<image>:<tag>

docker ps --filter name=<container-name>
curl -sS http://127.0.0.1:<HOST_PORT>/health
Deployment note: The actual environment variables, volumes, networks, secrets and health endpoint must come from the application's approved deployment definition. Do not invent them in this generic guide.

13. Assign Domain & Configure Nginx

13.1 Create the site configuration

sudo nano /etc/nginx/sites-available/<domain>

Example reverse-proxy configuration:

server {
    listen 80;
    listen [::]:80;
    server_name <domain>;

    location / {
        proxy_pass http://127.0.0.1:<HOST_PORT>;
        proxy_http_version 1.1;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        proxy_connect_timeout 30s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
}

13.2 Enable and test

sudo ln -s /etc/nginx/sites-available/<domain> /etc/nginx/sites-enabled/<domain>
sudo nginx -t
sudo systemctl reload nginx

# Verify local routing through Host header
curl -sS -H 'Host: <domain>' http://127.0.0.1/
Existing-site safety: Do not overwrite unrelated Nginx site files. Use a dedicated file for the new domain and validate with nginx -t before reload.

14. SSL / HTTPS

After DNS and HTTP routing work, issue the certificate for the approved domain.

# Confirm Certbot is available
sudo certbot --version

# Issue/install certificate using Nginx integration
sudo certbot --nginx -d <domain>

# Verify HTTPS
curl -I https://<domain>/

# Check certificate details
openssl s_client -connect <domain>:443 -servername <domain> 
PASS: HTTPS reaches the expected service, certificate is valid for the domain, no browser certificate warning exists, and renewal dry-run succeeds.

15. Evidence, Daily Record & Handover

FieldEntry
Date / Time____________________________
Operator____________________________
Server hostname____________________________
Overall statusGREEN / AMBER / RED
DockerPASS / WARN / FAIL
Domain / HTTPSPASS / WARN / FAIL
PostgreSQLPASS / WARN / FAIL / N/A
MongoDBPASS / WARN / FAIL / N/A
Application smoke testPASS / WARN / FAIL
Critical issue / ticket____________________________
Escalated to____________________________
Business notifiedYES / NO
Operator sign-off____________________________

Evidence standard

  • Record the exact time of the failed test.
  • Capture command output that demonstrates the issue.
  • Record affected domain, container, endpoint and database if known.
  • Never paste passwords, API keys, JWTs, private keys or database credentials into tickets/chats.
  • Use ticket/incident IDs to correlate repeated failures.
  • After restoration, repeat the original failed test and record the recovery result.

16. Safety & Change Rules

Allowed during normal RFB

  • Read-only server/resource checks
  • Docker status/log inspection
  • Nginx syntax validation
  • DNS/HTTPS/API checks
  • Read-only PostgreSQL/MongoDB checks
  • Application smoke testing
  • Evidence collection

Do not do without authorization

  • Restart/stop production services as a routine check
  • Edit Nginx or environment files
  • Rotate certificates without procedure
  • Delete containers/images or broad Docker prune
  • Terminate PostgreSQL sessions
  • Run destructive SQL
  • Delete/modify server or database data
Non-DevOps handover: An authorized backup operator may run the read-only checks, compare docker ps -a to inventory, run nginx -t where permitted, run domain/database connectivity checks and perform the documented smoke test. They should capture evidence and escalate rather than make production changes.

17. One-Page Quick Run

For experienced operators, this is the first-pass readiness sequence. It does not replace the full checklist when a check fails.

# Server
hostnamectl --static && uptime && free -h && df -hT
sudo systemctl --failed
sudo systemctl is-active docker nginx postgresql mongod 2>/dev/null || true

# Docker
 docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
docker ps -a --filter status=restarting
docker ps -a --filter status=exited
docker system df

# Network / Nginx
sudo nginx -t
sudo ss -lntp

# PostgreSQL
pg_isready
sudo -u postgres psql -c "SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database WHERE datistemplate=false ORDER BY pg_database_size(datname) DESC;"
sudo -u postgres psql -c "SELECT schemaname, relname, n_dead_tup, last_autovacuum FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 10;"

# MongoDB, if applicable
mongosh --quiet --eval 'db.adminCommand({ ping: 1 })' 2>/dev/null || true

# Logs / capacity
sudo journalctl --disk-usage
sudo journalctl --since 'today' -p err..alert --no-pager | tail -n 100

# Critical HTTPS endpoint
curl -sS -o /dev/null -w 'HTTPS=%{http_code} TIME=%{time_total}\n' https://<critical-domain>/
Final decision: Compare results with the service inventory, run the required application/API smoke test, record evidence and communicate GREEN, AMBER or RED.

Governance

Update this guide whenever a production domain, Docker container, port mapping, reverse-proxy route, database architecture, critical business flow, authorization mechanism, cleanup/retention policy or ownership changes. Review at least quarterly and after major infrastructure changes.

Version 2.1 • MR2K SOLUTIONS • Internal Company Operations