🌍 Server Configuration Guide for Different Languages & Frameworks
🚀 How Different Languages Serve Applications
Language / Framework | How It Serves | Alternative 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 |
PHP | Serves via Apache/Nginx | php -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 / Angular | Builds to static files (dist/ , build/ ) | Serve with Nginx, Apache, Netlify |
Next.js / Nuxt.js / SvelteKit | Runs on a port in SSR mode, static in SSG mode | Use Nginx for SSR or deploy statically |
Static HTML, CSS, JS | Directly served as static files | Use Nginx, Apache, Vercel, Netlify |
🎯 Common Default Ports for Different Languages
Language/Framework | Default Port | Can Be Changed? | How to Change It? |
---|---|---|---|
Node.js (Express, NestJS) | 3000 | ✅ Yes | app.listen(4000); |
Python (Flask) | 5000 | ✅ Yes | app.run(port=8080) |
Python (Django) | 8000 | ✅ Yes | python manage.py runserver 8081 |
Python (FastAPI) | 8000 | ✅ Yes | uvicorn main:app --port 8082 |
Java (Spring Boot) | 8080 | ✅ Yes | server.port=9090 in application.properties |
C# (.NET Core) | 5000, 5001 (HTTPS) | ✅ Yes | dotnet run --urls http://localhost:7000 |
Go (Golang HTTP server) | 8080 | ✅ Yes | http.ListenAndServe(":9090", nil) |
Rust (Rocket, Actix) | 8000 | ✅ Yes | ROCKET_PORT=9090 or in code |
Ruby (Rails, Sinatra) | 3000 | ✅ Yes | rails server -p 4000 |
PHP (Built-in Server) | 8000 | ✅ Yes | php -S localhost:9000 |
C++ (Crow, Wt) | 18080 | ✅ Yes | Change in code app.port(9095).run(); |
🛠️ Nginx Configuration for Different Languages
📌 When to Use Different Nginx Configurations?
Config Type | When to Use | Example |
---|---|---|
Port Number (listen ) | When Nginx listens for requests or proxies traffic | listen 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!🎉