---
title: "Discussion on \"Deploying web app with Nginx and Cloudflare\" | Hashnode"
description: "Discussion on \"Deploying web app with Nginx and Cloudflare\". This setup is for Django app but can also applies to other platform as well. The general setup before we get into details:-\n\nRun django with gunicorn\n\nManage the gunicorn process with systemd\n\nNginx as reverse proxy that forward incoming requests to ..."
url: "https://hashnode.com/posts/deploying-web-app-with-nginx-and-cloudflare/67368c7938042c09f7df7d78"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Deploying web app with Nginx and Cloudflare](https://grep.koditi.my/deploying-web-app-with-nginx-and-cloudflare?utm_source=hashnode&utm_medium=feed)

This setup is for Django app but can also applies to other platform as well. The general setup before we get into details:- Run django with gunicorn Manage the gunicorn process with systemd Nginx as reverse proxy that forward incoming requests to ...

Nov 14, 2024 · 3 min read · grep.koditi.my  
Read the article

-   [#nginx](https://hashnode.com/tag/nginx)
-   [#cloudflare](https://hashnode.com/tag/cloudflare)
-   [#django](https://hashnode.com/tag/django)
-   [#lightsail](https://hashnode.com/tag/lightsail)

## Written by

[Kamal Mustafa](https://hashnode.com/@k4ml)

@k4ml

  
[View profile](https://hashnode.com/@k4ml)

I am a web developer focusing on building web application using Python and Django. Full profile on https://kamal.koditi.my/.

## Responses 2

Markdown supported · ⌘↵ to post

[Node Edge Ops](https://hashnode.com/@nodeedgeops)

[Nov 4](https://hashnode.com/posts/deploying-web-app-with-nginx-and-cloudflare/67368c7938042c09f7df7d78/comment/6aeba12a1699b20024d140f0)

Useful pairing of nginx as the origin edge with Cloudflare in front. The ops trap I still see is double compression or double caching: Cloudflare already may gzip and cache, so turning gzip and a long proxy\_cache on at nginx without aligning Cache-Control just wastes CPU and makes purges confusing. I terminate TLS at Cloudflare or at nginx once, not both with conflicting redirects, and I forward the real client scheme via CF-Connecting-IP / X-Forwarded-Proto into the Node app so absolute URLs stay https.

After cutover I hit the app hostname with a cache-busting query and again without, comparing CF-Cache-Status and the origin access log. A permanent HIT at the CDN while Node never sees traffic is fine for static; for authenticated API paths I set Cache-Control private or bypass at Cloudflare and leave nginx as a thin reverse proxy with Host plus forwarded headers only. Also confirm websocket or long-poll paths are excluded from CDN caching, or clients reconnect forever while the edge serves a stale 200.
