Skip to content

Harshit-RV/nginx-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nginx Route-Based Proxy

A lightweight Nginx proxy server that handles route-based forwarding to multiple backend applications. This project demonstrates how to set up a reverse proxy using Nginx to route traffic to different backend services based on URL paths.

Project Structure

.
├── app1/           # Backend application 1 (runs on port 3000)
├── app2/           # Backend application 2 (runs on port 4000)
├── nginx/
│   └── nginx.conf  # Nginx configuration file
└── Dockerfile      # Docker configuration for the proxy

Features

  • Route-based request forwarding
  • Multiple backend service support
  • Clean URL rewriting
  • Docker containerization support

Routing Configuration

The proxy is configured to forward requests based on the following rules:

  • Requests to /app1/* are forwarded to http://localhost:3000
  • Requests to /app2/* are forwarded to http://localhost:4000

Getting Started

Prerequisites

  • Docker
  • Nginx (if running locally)

Running with Docker

  1. Build the Docker image:

    docker build . -t nginx-proxy
  2. Run the container:

    docker run -p 80:80 nginx-proxy

Running Locally

  1. Ensure Nginx is installed on your system
  2. Copy the nginx.conf to your Nginx configuration directory
  3. Start Nginx:
    nginx -c /path/to/nginx.conf

Configuration

The main configuration is in nginx/nginx.conf. The configuration includes:

  • Upstream server definitions for each backend
  • Route-based location blocks
  • URL rewriting rules

Usage Examples

  • Access app1: http://localhost/app1/
  • Access app2: http://localhost/app2/

Contributing

Feel free to submit issues and enhancement requests.

About

Ngixn Proxy for Route based forwarding

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published