Skip to content

nginx configuration process

AJprogramming123 edited this page Jun 20, 2025 · 1 revision

Nginx Setup

worker_process - an OS-level process that can handle many connections at once

  • how long each request takes
  • Whether your backend (Flask) is fast
  • Available CPU cores
  • What else the server is doing

One visitor does not block another. A single worker can juggle multiple requests using non-blocking I/O.

When someone visits your site, Nginx serves static files directly from disk: HTML, CSS, JS, images.

Nginx can serve these blazingly fast without even touching Flask or Docker.

Modern browsers cache this stuff, so repeat visits don’t even ask your server — they just check for updates using headers like ETag or Last-Modified.

So When Does worker_processes Matter?
API Calls / Dynamic Requests (Flask)


events {
    worker_connections 50;
}

For now i want to keep this connection to a limitation of 50 users to not overwhelm my pi incase of DDOS attacks


http {
    server {
        listen 80;
        server_name partagoemailbreach.xyz;

On port 80 you listen to partagoemailbreach.xyz domain which states it will only match requests sent to this domain name only and it listens on port 80 but on the container i set up


Proxy Traffic to Flask container

location / {
    proxy_pass http://emailbreach-arm32:5000;

I set up a reverse proxy because i want nginx to take the incoming client requests (like from a browser), and forward them to my backend service, then send back the response to the client.

  • The reverse proxy sits in front of the server to protect and manage access to the backend.

  • What nginx does to better the performance:

    • manipulate requests, security to never talk to flask directly, nginx can handle HTML/CSS/Images (not in this case)
    • it can terminate SSL or add it, like we saw with connection we can determine how many can see my webpage at once

Headers or in short information about the call (status)

  • See which domain the request came from -> proxy_set_header Host $host;
  • See the client IP address (Fail2ban utilization or in this block it through) -> proxy_set_header X-Real-IP $remote_addr;

Clone this wiki locally