ThishVerse Logo
THISHVERSE
HomeBlogAboutContact
Back to all posts
Web Development

Nginx කියන්නේ මොකක්ද?

Nginx කියන්නේ මොකක්ද, ඒක වැඩ කරන්නේ කොහොමද?

HHirun Thishakya
September 3, 2026
5 min read
Nginx කියන්නේ මොකක්ද?

ඔයා Web Development හෝ Backend Development කරලා තියෙනවා නම් Nginx කියන නම අහලා ඇති.

Nginx (උච්චාරණය කරන්නේ “Engine-X”) කියන්නේ high-performance web server එකක්. ඒ වගේම එය reverse proxy, load balancer, සහ HTTP cache එකක් විදිහටත් භාවිතා කරන්න පුළුවන්.

සරලව කිව්වොත්,

Nginx කියන්නේ Website එකකට හෝ Application එකකට එන Web Traffic එක manage කරලා, ඒ requests නිවැරදි තැනට යවන software එකක්.

උදාහරණයක් විදිහට ඔයා:

https://example.com

වෙත යන විට, ඔයාගේ request එක නිවැරදි Website එක හෝ Application එක වෙත යන්න ඕන.

මේ අතරමැදි traffic එක handle කරන්න Nginx භාවිතා කරන්න පුළුවන්.


Nginx එක Receptionist කෙනෙක් වගේ

ලොකු Office Building එකක් ගැන හිතන්න.

Visitor කෙනෙක් ආවම එයා කෙලින්ම ඕනෑම office එකකට යන්නේ නැහැ. මුලින්ම receptionist ළඟට යනවා.

Receptionist බලනවා:

  • ඔයා කවුද?

  • ඔයාට යන්න ඕන කොහෙද?

  • ඔයාගේ request එක handle කරන්න ඕන department එක මොකක්ද?

ඊට පස්සේ ඔයාව නිවැරදි තැනට යවනවා.

Nginx එකත් මේ වගේ.

User
  ↓
Nginx
  ↓
Application / Website / Server

User ගෙන් එන request එක මුලින්ම Nginx වෙත එනවා. ඊට පස්සේ Nginx ඒ request එක handle කරන ආකාරය තීරණය කරනවා.


Nginx එකෙන් කරන්න පුළුවන් දේවල්

Nginx එකේ ප්‍රධාන භාවිතයන් කිහිපයක් තියෙනවා.

1. Web Server එකක් ලෙස

Nginx එකට Website එකක තියෙන files කෙලින්ම serve කරන්න පුළුවන්.

උදාහරණ:

  • HTML

  • CSS

  • JavaScript

  • Images

  • Videos

  • Fonts

උදාහරණයක්:

User
  ↓
Nginx
  ↓
index.html

User කෙනෙක් Website එකකට request කළාම, Nginx එකට අවශ්‍ය files කෙලින්ම ලබා දෙන්න පුළුවන්.

ඒ නිසා Nginx static websites host කිරීම සඳහාත් බහුලව භාවිතා වෙනවා.


2. Reverse Proxy එකක් ලෙස

Nginx භාවිතා කරන ඉතාමත් common ක්‍රමයක් තමයි Reverse Proxy එකක් ලෙස භාවිතා කිරීම.

උදාහරණයක් විදිහට ඔයාගේ Node.js application එක:

localhost:3000

වල run වෙනවා කියලා හිතමු.

User කෙනෙක්ට:

http://example.com:3000

වගේ URL එකක් භාවිතා කරන්න අවශ්‍ය නැහැ.

ඒ වෙනුවට Nginx එක Application එක ඉදිරියෙන් තබන්න පුළුවන්.

User
  ↓
example.com
  ↓
Nginx
  ↓
Node.js Application
localhost:3000

User දකින්නේ:

https://example.com

විතරයි.

Nginx request එක ලබාගෙන ඒක Node.js application එකට forward කරනවා.

මේ ක්‍රියාවලියට කියන්නේ Reverse Proxying කියලා.


3. Load Balancing

ඔයාගේ Website එකට users ලක්ෂ ගණනක් එන්න පටන් ගත්තොත් එක Server එකකට ඒ සියලු requests handle කරන්න අමාරු වෙන්න පුළුවන්.

එතකොට Application එක Servers කිහිපයක run කරන්න පුළුවන්.

             ┌── Server 1
             │
User → Nginx ├── Server 2
             │
             └── Server 3

Nginx එකට incoming requests මේ Servers අතර distribute කරන්න පුළුවන්.

උදාහරණයක්:

Request 1 → Server 1
Request 2 → Server 2
Request 3 → Server 3
Request 4 → Server 1

මේකට කියන්නේ Load Balancing කියලා.

එමඟින් එක Server එකකට අධික traffic එකක් පැමිණීම අඩු කරගන්න පුළුවන්.


4. HTTPS සහ SSL/TLS

Nginx එකට HTTPS connections handle කරන්නත් පුළුවන්.

උදාහරණයක්:

https://example.com

Nginx එකට encrypted HTTPS request එක receive කරලා, backend application එක සමඟ communicate කරන්න පුළුවන්.

මේ ක්‍රියාවලිය බොහෝවිට SSL/TLS Termination කියලා හඳුන්වනවා.

ඒ නිසා හැම Application Server එකකම HTTPS configuration එක වෙන වෙනම කරනවා වෙනුවට, Nginx එක ඉදිරියෙන් තියලා HTTPS handling එක එතනින් manage කරන්න පුළුවන්.


5. Caching

Nginx එකට frequently requested content cache කරන්නත් පුළුවන්.

හිතන්න එකම image එක 10,000 users ලා request කරනවා කියලා.

Caching නැත්නම්:

Users → Application → Database/Storage

Application එකට එකම content එක නැවත නැවත process කරන්න සිදුවෙන්න පුළුවන්.

Caching භාවිතා කළොත්:

Users → Nginx → Cached Content

Nginx එකට cache කරලා තියෙන content එක කෙලින්ම return කරන්න පුළුවන්.

මේකෙන්:

  • Website performance වැඩි කරගන්න පුළුවන්.

  • Backend server එකේ workload එක අඩු වෙනවා.

  • Response time එක අඩු කරගන්නත් පුළුවන්.


Nginx සමඟ Node.js

Nginx සහ Node.js එකට භාවිතා කිරීම ගෙඩක් common.

Node.js application එක:

localhost:3000

වල internally run වෙනවා කියලා හිතමු.

Nginx එක public-facing server එක ලෙස වැඩ කරන්න පුළුවන්.

              Internet
                  ↓
             Nginx :80/:443
                  ↓
             Node.js :3000
                  ↓
               Database

මෙතනදී,

Nginx handle කරන්නේ:

  • Incoming requests

  • HTTPS

  • Static files

  • Reverse proxying

  • Load balancing

  • Caching

Node.js handle කරන්නේ:

  • Application logic

  • API requests

  • Authentication

  • Business logic

  • Database operations

ඒ නිසා Nginx කියන්නේ Node.js වෙනුවට භාවිතා කරන backend එකක් නෙමෙයි.

ඒක බොහෝවිට Node.js application එකට ඉදිරියෙන් වැඩ කරන layer එකක්.


Node.js විතරක් භාවිතා නොකරන්නේ ඇයි?

මෙතනදී ඔයාට ප්‍රශ්නයක් එන්න පුළුවන්:

Node.js එකටත් HTTP requests receive කරන්න පුළුවන්. එහෙනම් Nginx ඕන ඇයි?

Development කරන වෙලාවේ Application එක direct run කිරීම සාමාන්‍ය දෙයක්.

Browser → Node.js

නමුත් production environment එකකදී Nginx එකෙන් තවත් වැදගත් features ගොඩක් ලබාගන්න පුළුවන්.

උදාහරණ:

  • Reverse proxy

  • Efficient static file serving

  • HTTPS handling

  • Load balancing

  • Caching

  • Request management

ඒ නිසා production architecture එකක් මේ වගේ වෙන්න පුළුවන්:

User
 ↓
Nginx
 ↓
Backend Application
 ↓
Database

Nginx vs Apache

Nginx සහ Apache HTTP Server කියන්නේ දෙකම ජනප්‍රිය Web Servers.

Feature

Nginx

Apache

Web Server

✅

✅

Reverse Proxy

✅

✅

Load Balancing

✅

✅

HTTPS

✅

✅

Static Files

Excellent

Excellent

Configuration Style

Central configuration

Flexible configuration

Common Use

Reverse proxy & modern deployments

Traditional web hosting & flexible setups

දෙකම powerful Web Servers.

ඒ නිසා “Nginx, Apache වලට වඩා හොඳයි” කියලා කියන්න බැහැ. තෝරාගැනීම Application එකේ requirements සහ architecture එක මත depend වෙනවා.


Nginx භාවිතා කරන්නේ කොහෙද?

Nginx විවිධ ආකාරයේ systems වල භාවිතා වෙනවා.

🌐 Website Hosting

Websites සහ static files serve කිරීමට.

🔌 API Servers

API requests backend applications වෙත forward කිරීමට.

☁️ Cloud Deployments

Cloud server එකක run වෙන Application එකකට entry point එකක් ලෙස.

⚙️ Microservices

Requests විවිධ services වෙත route කිරීමට.

උදාහරණයක්:

/api/users     → User Service
/api/orders    → Order Service
/api/products  → Product Service

📈 High-Traffic Applications

Traffic එක Servers කිහිපයක් අතර distribute කිරීමට.


Real-World Example එකක්

ඔයා Online Shopping Website එකක් හදනවා කියලා හිතමු.

Architecture එක මේ වගේ වෙන්න පුළුවන්:

                    Users
                      ↓
                    Nginx
                  ↙      ↘
             Frontend    Backend
                          ↓
                       Database

User කෙනෙක්:

example.com/products

request කරනවා.

Nginx එක request එක receive කරනවා.

ඊට පස්සේ ඒක:

/products → Backend API

වෙත යවනවා.

Backend එක Database එකෙන් products ලබාගෙන response එක Nginx හරහා user වෙත යවනවා.

ඒ නිසා Nginx එක Web Application එකේ ඉදිරිපස තිබෙන traffic manager කෙනෙක් වගේ වැඩ කරනවා.


Developers ලාට Nginx අවශ්‍යද?

හැම Developer කෙනෙක්ටම Nginx භාවිතා කරන්න අවශ්‍ය නැහැ.

Local development කරන වෙලාවේ Application එක direct run කරන්න පුළුවන්.

Browser → Node.js

නමුත් Application එක production environment එකකට deploy කරනකොට Nginx ඉතා ප්‍රයෝජනවත් වෙනවා.

විශේෂයෙන්:

  • Linux Servers

  • Node.js

  • PHP

  • Laravel

  • React/Next.js deployments

  • APIs

  • Docker

  • Cloud Servers

  • Microservices

  • DevOps

වැනි technologies සහ environments සමඟ Nginx බහුලව භාවිතා වෙනවා.


Nginx ගැන මතක තියාගන්න ලේසිම ක්‍රමය තමයි මේ diagram එක:

                     INTERNET
                         ↓
                      NGINX
                  ↙     ↓      ↘
             Website   API    Server 2
                        ↓
                    Database

Nginx කියන්නේ User සහ Application එක අතර සිටින traffic manager කෙනෙක් වගේ.

User ගෙන් request එක ලබාගෙන, ඒක serve කරන්න හෝ නිවැරදි backend service එක වෙත යවන්න Nginx එකට පුළුවන්.

Tags:DevOpsNginxWeb ServerReverse ProxyLoad BalancingHTTPSBackendWeb Hosting

Did you find this article helpful?

Related Articles

View Post
Azure වලින් මොනවද කරන්න පුළුවන්?
Cloud Computing
October 7, 2026

Azure වලින් මොනවද කරන්න පුළුවන්?

Microsoft Azure කියන්නේ විවිධ විදිහෙ දේවල් ගොඩක් කරන්න පුලුවන් cloud platform එකක්.

View Post
මොනවද මේ Linux Shell වර්ග?
DevOpsFeatured
October 2, 2026

මොනවද මේ Linux Shell වර්ග?

Linux වල තියෙන Bash, Zsh, Fish, Dash වගේ Shells අතර වෙනස්කම්

View Post
Flutter සහ React Native
Programming
September 24, 2026

Flutter සහ React Native

Mobile App Development එකට හොද මොකක්ද?

ThishVerse Logo
THISHVERSE
|

© 2026 ThishVerse. All rights reserved.

PrivacyTerms
|By Thish
Comments (0)

Sign in to join the conversation

No comments yet. Be the first to comment!