This project is a HTTP server (Mini NGINX) that can handle multiple clients at the same time. It is able to serve static files and execute CGI scripts. It handles GET, POST and DELETE requests.
make./webserv [config_file]Example:
./webserv config/basic.confCtrl + C- Open a web browser and go to http://localhost:1313/ to see the default page.
- Config port is
1313in the example config file. Modify the port number according to the config file.
- Config port is
- You can also use
curlto send requests to the server.-Hflag is used to add headers to the request.-Xflag is used to specify the request method.
curl -X GET http://localhost:1313/- server_name [name of the server]
- listen [port number]
- client_max_body_size [size in Mb]
- error_page [error code] [path to error file]
Inside a server block, we can have zero to many location blocks.
- root [path] -> appends this path after the entry path
- index [file name] -> default page if no file specified in the uri
- autoindex [on|off] -> enables/disables the listing of directory
- allowed_methods [GET|POST|DELETE] -> defines the allowed methods
- cgi [.extension] [path to executable]
- upload_file_path [directory path] -> location of the files to download
- Run the server with the example config file.
make ./webserv config/basic.conf
- Open a web browser and go to http://localhost:1313/ to see the default page (with directory listing).
- Check cgi script by going to http://localhost:1313/ruby/
- Check the error page by going to http://localhost:1313/some_invalid_path
- Send a file using
curl.touch test.txt curl -X POST -F "file=@./test.txt" http://localhost:1313/ - Check the uploaded file by going to http://localhost:1313/upload/
- Delete the uploaded file using
curl.curl -X DELETE http://localhost:1313/upload/test.txt
- Check the deleted file by going to http://localhost:1313/upload/
- Check cookie by going to http://localhost:1313/python/