← Back

Whitenoise & Git Security — Static Files 404, Token Ke Publish

devops django git security

Latar Belakang

Setelah Cloudflare tunnel nyala, static files (CSS, logo) 404. collectstatic udah di entrypoint, tapi Django DEBUG=False gak serve static — perlu Whitenoise.

Juga pas commit, file token cloudflare (isi token asli) ikut ke-track karena git add -A.

Masalah

  1. Admin & halaman public gak ada CSS — HTTP 404 & MIME mismatch
  2. Token Cloudflare bocor ke git history (walau cuma bentar di private repo)

Solusi

Static Files

  • Tambah whitenoise di requirements.txt
  • WhiteNoiseMiddleware di MIDDLEWARE (setelah SecurityMiddleware)
  • STORAGES config pake CompressedStaticFilesStorage
  • entrypoint.sh udah jalanin collectstatic --noinput

Git Security

  • Hapus file token cloudflare dari tracking
  • Tambah token* ke .gitignore biar gak ke-commit lagi
  • git commit --amend + git push --force-with-lease bersihin history

Catatan

  • Token sempat terpublish ke GitHub walau bentar. Ideally harus di-rotate, tapi untuk sekarang dibiarkan dulu — repo private.
  • .gitignore sekarang include token* — semua file berawalan token otomatis diabaikan git.
  • Format: git add -A bahaya kalo ada file sensitif. Better git add <specific files>.

Last updated 24 Jul 2026 13:09

Comments