Nginx++ is a high-performance, low-latency HTTP server written in C++. Designed to handle a wide range of HTTP requests efficiently, it supports advanced features like CGI scripting, file uploads, and custom configurations. Built with a focus on speed and reliability. It also includes a default index page with a CGI script that allows users to test all supported HTTP requests directly from their browser.
- High Performance: Optimized for speed and low latency, capable of handling thousands of concurrent connections.
- HTTP/1.1 Protocol Support: Fully supports
GET
,POST
,PUT
, andDELETE
requests. - CGI Support: Execute dynamic content generation using CGI scripts (e.g., Python, PHP, Perl).
- File Uploads: Easily upload files with configurable storage locations.
- Auto Indexing: Automatically generates directory listings for directories without an
index
file. - Custom Configuration: Flexible configuration via
servIO.conf
to tailor the server to your needs. - Dockerized: Easy deployment using Docker for seamless integration into any environment.
WebServer is built with performance in mind. It uses efficient I/O multiplexing and a lightweight architecture to ensure minimal latency and maximum throughput. Whether you're serving static files or executing CGI scripts, WebServer delivers blazing-fast responses.
Thanks to its non-blocking design and optimized request handling, WebServer ensures low-latency responses even under heavy load. This makes it ideal for real-time applications and high-traffic websites.
With a simple configuration file (servIO.conf
) and a default index page that includes a CGI script, WebServer is incredibly easy to set up and use. You can test all supported HTTP requests directly from your browser without needing external tools.
WebServer is fully Dockerized, making it easy to deploy in any environment. Whether you're running it locally or in the cloud, Docker ensures consistent and hassle-free deployment.
nginx++/
βββ Dockerfile
βββ LICENSE
βββ Makefile
βββ main.cpp
βββ .dockerignore
βββ Configuration/
β βββ HTTP.cpp
β βββ HTTP.hpp
β βββ LocationConf.cpp
β βββ LocationConf.hpp
β βββ MainConf.cpp
β βββ MainConf.hpp
β βββ ServerConf.cpp
β βββ ServerConf.hpp
β βββ servIO.conf
βββ Core/
β βββ Client.cpp
β βββ Client.hpp
β βββ CoreServer.cpp
β βββ CoreServer.hpp
β βββ Selector.hpp
β βββ Server.cpp
β βββ Server.hpp
βββ Http/
β βββ CGI.cpp
β βββ DefaultPages.cpp
β βββ DefaultPages.hpp
β βββ DeleteRequest.cpp
β βββ DeleteRequest.hpp
β βββ GetRequest.cpp
β βββ GetRequest.hpp
β βββ IRequest.hpp
β βββ MethodsUtils.cpp
β βββ PostRequest.cpp
β βββ PostRequest.hpp
β βββ ProcessRequest.cpp
β βββ ProcessRequest.hpp
β βββ PutRequest.cpp
β βββ PutRequest.hpp
β βββ Response.cpp
β βββ Response.hpp
β βββ ResponseUtils.cpp
βββ Parser/
β βββ Lexer.cpp
β βββ Lexer.hpp
β βββ Parser.cpp
β βββ Parser.hpp
β βββ Token.cpp
β βββ Token.hpp
βββ includes/
β βββ Constants.hpp
βββ utils/
β βββ utils.cpp
β βββ utils.hpp
βββ www/
βββ image/
βββ media/
βββ other/
βββ main.cpp
βββ test.txt
- C++ Compiler (GCC or Clang)
- Make
- Docker (optional, for containerized deployment)
-
Clone the repository:
git clone https://github.com/abizyane/WebServer.git cd WebServer
-
Build the Server: Use the
Makefile
to compile the server:make
-
Run the Server: Start the server using the compiled binary:
./nginx++
-
Access the Server: Open your browser or use
curl
to access the server athttp://localhost:8080
.
-
Build and Run the Docker Container: Use the
Makefile
to build and start the server:make up
This will:
- Build the Docker image.
- Start the container and expose ports
8080
,5500
, and3333
.
-
Stop the Server: To stop the server, run:
make down
-
Restart the Server: To restart the server, run:
make dc_re
The server includes a default index page that features a CGI-powered interface. This interface allows you to test all supported HTTP requests (GET
, POST
, PUT
, DELETE
) directly from your browser. Simply navigate to http://localhost:8080/
and use the interactive form to send requests and view responses.
-
GET Request: Fetch the default page:
curl http://localhost:8080/
-
Auto Indexing: If the directory has no
index
file, the server will generate an auto-indexed page. For example:curl http://localhost:8080/www/
-
CGI Script: Execute a CGI script (e.g.,
app.py
):curl http://localhost:8080/www/scripts/app.py
The server configuration is defined in Configuration/servIO.conf
. You can modify this file to change server settings such as ports, root directories, and allowed methods.
Example configuration:
http {
root /Webserv/www/;
allow GET POST DELETE PUT;
upload_store /Upload;
server {
listen 5500;
listen 8080;
server_name localhost;
location / {
error_page 404 404.html;
cgi 0.0.0.0:90;
autoindex on;
index indexxx.html app.py;
client_body_max_size 300;
cgi .py .js .php .pl;
}
location /www/scripts {
root /Webserv/www/scripts;
autoindex on;
cgi .py;
}
location /blog {
deny DELETE;
}
location /container_rootdir {
deny POST;
deny DELETE;
deny PUT;
root /;
autoindex on;
}
}
server {
listen 3333;
location / {
return 301 http://localhost:8080;
}
}
}
This project is licensed under the MIT License - see the LICENSE file for details.
- Zakaria El Bouzkri π§βπ»
- Achraf Bizyane π§βπ»
- Noureddine Akebli π§βπ»
- The simplicity and performance of Nginx.
- The power of C++.