Skip to content

Commit c1d340d

Browse files
authored
Merge pull request #64 from codeharborhub/dev-1
Docs: updated
2 parents 68ffda8 + 5ee1e3e commit c1d340d

File tree

5 files changed

+671
-5
lines changed

5 files changed

+671
-5
lines changed

docs/internet/cdn.mdx

Lines changed: 150 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,150 @@
1-
<ComingSoon />
1+
---
2+
title: "Understanding CDNs (Content Delivery Networks)"
3+
description: "Learn how CDNs make websites faster, more reliable, and globally accessible by caching and delivering content from distributed servers close to users."
4+
tags: [cdn, performance, caching, networking, internet, web, optimization]
5+
sidebar_label: CDN
6+
---
7+
8+
Modern websites and apps serve millions of users worldwide but sending data directly from one central server to everyone would be slow and inefficient. That’s where **CDNs (Content Delivery Networks)** come in.
9+
10+
A **CDN** is a distributed network of servers located across the globe that **deliver content faster** by caching it closer to users.
11+
12+
## What Is a CDN?
13+
14+
A **Content Delivery Network (CDN)** is a group of geographically distributed servers that work together to deliver web content such as images, videos, CSS, JavaScript, and HTML pages to users based on their location.
15+
16+
Instead of fetching data from your website’s origin server every time, a CDN stores (or *caches*) copies of static files on its **edge servers** around the world.
17+
18+
```mermaid
19+
graph TD
20+
A[User in India] --> B[Nearest Edge Server - Mumbai]
21+
B --> C[Origin Server - USA]
22+
A2[User in France] --> D[Nearest Edge Server - Paris]
23+
D --> C
24+
C -->|Updates Cached Data| B
25+
C -->|Updates Cached Data| D
26+
```
27+
28+
> The closer the user is to the CDN edge server, the faster the content loads.
29+
30+
## How a CDN Works
31+
32+
<Tabs>
33+
<TabItem value="simple" label="Simple View" default>
34+
A CDN keeps cached copies of your website’s files on global servers.
35+
When a user visits your site, they automatically connect to the **closest** CDN node, reducing latency and improving speed.
36+
</TabItem>
37+
<TabItem value="technical" label="Technical View">
38+
1. User requests a file (e.g., `index.html`).
39+
2. DNS redirects the request to the **nearest CDN edge node**.
40+
3. The edge server checks if it has a **cached copy** of the resource.
41+
4. If cached, it serves the file directly (cache hit).
42+
5. If not cached, it fetches it from the **origin server**, caches it, and serves it to the user (cache miss).
43+
6. The process repeats for users worldwide.
44+
</TabItem>
45+
</Tabs>
46+
47+
## CDN Example (Simulation)
48+
49+
```jsx live
50+
function CDNExample() {
51+
const handleRequest = (cached) => {
52+
alert(cached ? "Served from CDN Edge (Cache Hit)" : "Fetched from Origin Server (Cache Miss)");
53+
};
54+
55+
return (
56+
<div style={{ textAlign: "center" }}>
57+
<h3>CDN Request Simulation</h3>
58+
<button onClick={() => handleRequest(true)}>Request Cached File</button>
59+
<button onClick={() => handleRequest(false)}>Request New File</button>
60+
</div>
61+
);
62+
}
63+
```
64+
65+
## Components of a CDN
66+
67+
| Component | Description |
68+
| ---------- | ------------ |
69+
| **Origin Server** | The main server where the original content is hosted. |
70+
| **Edge Server (PoP)** | CDN data centers close to users that cache content for faster delivery. |
71+
| **Cache** | Stored version of website files to avoid repeated requests to the origin. |
72+
| **DNS Routing** | Directs user requests to the nearest CDN node. |
73+
| **Load Balancer** | Distributes traffic efficiently between servers. |
74+
75+
## Example Flow: How a CDN Delivers a Web Page
76+
77+
```mermaid
78+
sequenceDiagram
79+
participant U as User Browser
80+
participant D as DNS Resolver
81+
participant E as CDN Edge Server
82+
participant O as Origin Server
83+
84+
U->>D: Request website (www.example.com)
85+
D-->>U: Resolve to nearest CDN Edge (Mumbai)
86+
U->>E: Request content
87+
E-->>U: Serve from Cache (if available)
88+
E->>O: Fetch new content (if cache miss)
89+
O-->>E: Send original content
90+
E-->>U: Deliver optimized response
91+
```
92+
93+
## Benefits of Using a CDN
94+
95+
| Benefit | Description |
96+
| -------- | ------------ |
97+
| **Faster Load Times** | Users connect to nearby servers, reducing latency. |
98+
| **Scalability** | Handles massive traffic loads without downtime. |
99+
| **Reliability** | Multiple edge servers ensure uptime even if one fails. |
100+
| **Security** | Protects against DDoS attacks and provides SSL/TLS encryption. |
101+
| **Cost Efficiency** | Reduces bandwidth usage and load on origin servers. |
102+
103+
## Performance Impact (Example)
104+
105+
If your site’s origin is in the USA and a visitor from India requests it:
106+
107+
| Delivery Type | Latency | Load Time | User Experience |
108+
| -------------- | -------- | ---------- | ---------------- |
109+
| **Without CDN** | 250 ms | 3.5s | Slow, laggy |
110+
| **With CDN (India Edge)** | 45 ms | 1.2s | Fast, smooth |
111+
112+
That’s nearly **3x faster**, thanks to edge caching.
113+
114+
## CDN Caching Strategies
115+
116+
| Strategy | Description |
117+
| ---------- | ------------ |
118+
| **Time-to-Live (TTL)** | Defines how long an asset stays cached before refresh. |
119+
| **Cache Invalidation** | Removes outdated content from CDN nodes. |
120+
| **Stale-while-revalidate** | Serves old content while fetching fresh data in the background. |
121+
122+
> Example: Cloudflare and Akamai use *smart caching* to automatically refresh only changed files.
123+
124+
## CDN and Security
125+
126+
Modern CDNs not only improve performance — they also **protect websites**.
127+
128+
### Built-in Security Features
129+
130+
* **DDoS Protection** – Blocks malicious traffic before it reaches the origin.
131+
* **WAF (Web Application Firewall)** – Filters harmful requests.
132+
* **TLS/SSL Termination** – Ensures encrypted data transfer.
133+
* **Bot Management** – Detects and mitigates automated attacks.
134+
135+
## Popular CDN Providers
136+
137+
| Provider | Description |
138+
| --------- | ------------ |
139+
| **Cloudflare** | Offers global caching, security, and edge compute features. |
140+
| **Akamai** | One of the oldest and largest CDN providers. |
141+
| **AWS CloudFront** | Integrated with Amazon Web Services. |
142+
| **Fastly** | Known for real-time caching and edge logic. |
143+
| **Google Cloud CDN** | Delivers content via Google’s backbone network. |
144+
145+
## Key Takeaways
146+
147+
* A **CDN** distributes your website’s content to servers closer to users, drastically improving performance.
148+
* It reduces **latency**, **bandwidth usage**, and **server load**.
149+
* CDNs use **edge caching** and **routing intelligence** to deliver fast, reliable, and secure content.
150+
* For global applications, CDNs are **essential for scalability and user experience**.

docs/internet/firewalls.mdx

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,152 @@
1-
<ComingSoon />
1+
---
2+
title: "Understanding Firewalls"
3+
description: "Learn what firewalls are, how they protect networks from unauthorized access, and explore the different types of firewalls used in modern Internet security."
4+
tags: [firewall, security, networking, internet, protection, cybersecurity]
5+
sidebar_label: Firewalls
6+
---
7+
8+
The Internet is a powerful and open system but that openness also creates risks. To keep networks secure, we rely on **firewalls**, the first line of defense against unwanted traffic, hackers, and cyberattacks.
9+
10+
## What Is a Firewall?
11+
12+
A **firewall** is a **security barrier** that monitors and controls incoming and outgoing network traffic based on a set of rules. It acts as a **filter between trusted and untrusted networks**, such as between your computer and the Internet.
13+
14+
:::info
15+
Think of a firewall as a security guard at the entrance of a building, checking IDs and only allowing authorized personnel to enter.
16+
17+
In simple terms, firewalls help ensure that only safe and approved data can pass through to your network.
18+
:::
19+
20+
```mermaid
21+
graph LR
22+
A[Internet] -->|Allowed Traffic| B(Firewall)
23+
B -->|Filtered & Safe| C[Internal Network]
24+
A -.->|Blocked Traffic| B
25+
```
26+
27+
## How Firewalls Work
28+
29+
Firewalls inspect **data packets** as they travel across networks. Each packet is analyzed against **security rules**, such as:
30+
31+
* Source and destination IP addresses
32+
* Port numbers
33+
* Protocols (HTTP, HTTPS, FTP, etc.)
34+
* Packet contents (in advanced firewalls)
35+
36+
<Tabs>
37+
<TabItem value="basic" label="Basic View" default>
38+
A basic firewall might allow web traffic (port 80/443) but block suspicious connections or file transfers on other ports.
39+
</TabItem>
40+
<TabItem value="technical" label="Technical View">
41+
1. Packet enters the firewall.
42+
2. Firewall checks **header information** (source, destination, port).
43+
3. Rules are applied — e.g., “block all incoming SSH except from admin IPs.”
44+
4. Packet is either **allowed**, **blocked**, or **logged** for review.
45+
</TabItem>
46+
</Tabs>
47+
48+
## Example: Simple Firewall Simulation
49+
50+
```jsx live
51+
function FirewallSimulator() {
52+
const handleRequest = (type) => {
53+
if (type === "http") alert("Allowed: Web traffic (Port 443)");
54+
else alert("Blocked: Unauthorized traffic (Port 23)");
55+
};
56+
return (
57+
<div style={{ textAlign: "center" }}>
58+
<h3>Firewall Traffic Filter</h3>
59+
<button onClick={() => handleRequest("http")}>Send HTTPS Request</button>
60+
<button onClick={() => handleRequest("telnet")}>Send Telnet Request</button>
61+
</div>
62+
);
63+
}
64+
```
65+
66+
## Types of Firewalls
67+
68+
Firewalls can operate at different layers of the network stack and offer varying levels of security:
69+
70+
| Type | Layer | Description |
71+
|------|--------|-------------|
72+
| **Packet-Filtering Firewall** | Network | Checks basic info like IPs and ports; fast but limited. |
73+
| **Stateful Inspection Firewall** | Transport | Tracks active connections and allows related packets. |
74+
| **Proxy Firewall** | Application | Intercepts and inspects data at the application layer (HTTP, FTP). |
75+
| **Next-Generation Firewall (NGFW)** | Multiple | Includes intrusion detection, malware filtering, and deep inspection. |
76+
| **Cloud Firewall (FWaaS)** | Cloud | Firewall-as-a-Service — protects cloud apps and virtual networks. |
77+
78+
```mermaid
79+
graph TD
80+
A[Packet Filtering] --> B[Stateful Inspection]
81+
B --> C[Proxy Firewall]
82+
C --> D[Next-Gen Firewall]
83+
D --> E[Cloud Firewall]
84+
```
85+
86+
## Firewall Rules Example
87+
88+
| Rule | Action | Description |
89+
|------|---------|-------------|
90+
| Allow TCP port 443 | Allow | Enable secure web browsing (HTTPS). |
91+
| Block TCP port 23 | Block | Disable Telnet — an insecure protocol. |
92+
| Allow ICMP from internal network | Allow | Permit internal ping requests. |
93+
| Block all inbound traffic by default | Block | Enforce a default-deny security posture. |
94+
95+
```bash
96+
# Example Linux UFW firewall commands
97+
sudo ufw default deny incoming
98+
sudo ufw allow 443/tcp
99+
sudo ufw deny 23/tcp
100+
sudo ufw enable
101+
```
102+
103+
## Network Placement of Firewalls
104+
105+
Firewalls can exist in multiple forms hardware, software, or cloud-based — and are typically placed between the **LAN** and **Internet**. In a typical home or office setup:
106+
107+
```mermaid
108+
graph LR
109+
A[Internet] --> B[Firewall]
110+
B --> C[Router]
111+
C --> D[Local Network - Devices]
112+
```
113+
114+
Some organizations use multiple layers of firewalls **perimeter firewalls** at the network edge and **internal firewalls** between departments or services.
115+
116+
## Stateful vs Stateless Firewalls
117+
118+
| Feature | Stateless Firewall | Stateful Firewall |
119+
|----------|-------------------|-------------------|
120+
| Tracks connections | No | Yes |
121+
| Security level | Basic | High |
122+
| Performance | Fast | Slightly slower |
123+
| Use case | Simple traffic filtering | Complex enterprise networks |
124+
125+
:::note
126+
Stateful firewalls are generally preferred for modern networks due to their ability to monitor ongoing connections and provide enhanced security.
127+
:::
128+
129+
## Firewall Limitations
130+
131+
While firewalls are powerful, they aren’t a complete solution on their own.
132+
133+
* Cannot detect **internal threats** or **phishing attacks**.
134+
* May slow down traffic if poorly configured.
135+
* Need **regular updates** to remain effective.
136+
* Must be combined with antivirus, intrusion detection, and monitoring tools.
137+
138+
## Real-World Examples of Firewalls
139+
140+
| Vendor | Product | Highlights |
141+
|--------|----------|------------|
142+
| **Cisco ASA** | Enterprise Firewall | Hardware-based security with advanced inspection. |
143+
| **Fortinet FortiGate** | Unified Threat Management | Combines firewall, VPN, and intrusion prevention. |
144+
| **Palo Alto Networks NGFW** | Next-Gen Firewall | Application-level inspection with ML-driven threat detection. |
145+
| **Cloudflare WAF** | Cloud Firewall | Protects websites from online attacks at the edge. |
146+
147+
## Key Takeaways
148+
149+
* A **firewall** is a traffic filter that protects your system from unauthorized access.
150+
* It uses predefined **rules** to allow or block network traffic.
151+
* Modern **Next-Gen Firewalls** combine inspection, intrusion prevention, and threat intelligence.
152+
* Firewalls are essential for **network security**, but should be part of a **multi-layered defense strategy**.

0 commit comments

Comments
 (0)