Skip to main content

🌍 Server Configuration Guide for Different Languages & Frameworks

🚀 How Different Languages Serve Applications

Language / FrameworkHow It ServesAlternative Ways
Node.js (Express, NestJS)Runs on a port (e.g., 3000)Use Nginx as a reverse proxy
Python (Flask, Django)Runs on a port (5000, 8000)Use Gunicorn + Nginx for production
Java (Spring Boot)Runs on a port (8080)Deploy with Apache Tomcat
C# (.NET)Runs on a port (5000, 5001)Use IIS or Nginx as a reverse proxy
Go (Golang)Runs on a port (8080, 8000)Use Caddy or Nginx as a reverse proxy
Ruby (Rails, Sinatra)Runs on a port (3000)Use Puma or Nginx for production
PHPServes via Apache/Nginxphp -S localhost:8000 for local dev
Rust (Rocket, Actix)Runs on a port (8000, 8080)Use Nginx as a reverse proxy
C++ (Crow, Wt)Runs on a port (18080, 8080)Can serve static files, use Nginx proxy
React / Vue / AngularBuilds to static files (dist/, build/)Serve with Nginx, Apache, Netlify
Next.js / Nuxt.js / SvelteKitRuns on a port in SSR mode, static in SSG modeUse Nginx for SSR or deploy statically
Static HTML, CSS, JSDirectly served as static filesUse Nginx, Apache, Vercel, Netlify

🎯 Common Default Ports for Different Languages

Language/FrameworkDefault PortCan Be Changed?How to Change It?
Node.js (Express, NestJS)3000✅ Yesapp.listen(4000);
Python (Flask)5000✅ Yesapp.run(port=8080)
Python (Django)8000✅ Yespython manage.py runserver 8081
Python (FastAPI)8000✅ Yesuvicorn main:app --port 8082
Java (Spring Boot)8080✅ Yesserver.port=9090 in application.properties
C# (.NET Core)5000, 5001 (HTTPS)✅ Yesdotnet run --urls http://localhost:7000
Go (Golang HTTP server)8080✅ Yeshttp.ListenAndServe(":9090", nil)
Rust (Rocket, Actix)8000✅ YesROCKET_PORT=9090 or in code
Ruby (Rails, Sinatra)3000✅ Yesrails server -p 4000
PHP (Built-in Server)8000✅ Yesphp -S localhost:9000
C++ (Crow, Wt)18080✅ YesChange in code app.port(9095).run();

🛠️ Nginx Configuration for Different Languages

📌 When to Use Different Nginx Configurations?

Config TypeWhen to UseExample
Port Number (listen)When Nginx listens for requests or proxies trafficlisten 80;
Build Path (root)When serving a frontend app (React/Vue/Angular)root /var/www/html/myapp/dist;
Public Path (root)When serving public assets (images, CSS, JS)root /var/www/html/myapp/public;

🌐 Example Nginx Config for Backend Apps (Node.js, Python, Java, etc.)

server {
listen 80;
server_name example.com;

location / {
proxy_pass http://localhost:3000; # Change the port accordingly
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
}

🎨 Example Nginx Config for Frontend Apps (React, Vue, Angular, etc.)

server {
listen 80;
server_name example.com;

root /var/www/html/myapp/dist; # Serve frontend build files
index index.html;

location / {
try_files $uri /index.html;
}
}

📋 Final Thoughts

Backend apps (Node.js, Flask, Go, Java, etc.) → Use proxy_pass http://localhost:<port>;
Frontend apps (React, Vue, Angular, etc.) → Serve from root /var/www/html/myapp/dist;
PHP apps (Laravel, WordPress, etc.) → Serve from root /var/www/html/public;

This guide should help you configure and manage different web applications efficiently! 🚀🔥


📌 Author: Asif Ahmad Khan
📅 Last Updated: March 2025
🛠 Contributions: Feel free to improve this guide!🎉