-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
7,382 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,15 @@ | |
# By: agaley <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2023/12/15 15:51:13 by agaley #+# #+# # | ||
# Updated: 2024/06/21 16:36:27 by agaley ### ########lyon.fr # | ||
# Updated: 2024/06/25 00:40:40 by agaley ### ########lyon.fr # | ||
# # | ||
# **************************************************************************** # | ||
|
||
NAME = webserv | ||
|
||
CXX = c++ | ||
CXXFLAGS = -Wall -Wextra -Werror -MMD -std=c++98 | ||
DEBUGFLAGS = -g3 -fsanitize=address | ||
DEBUGFLAGS = -g3 | ||
|
||
SRC_DIR = src | ||
OBJ_DIR = obj | ||
|
@@ -30,9 +30,9 @@ export NGINX_PORT_1 ?= 8000 | |
export NGINX_PORT_2 ?= 8001 | ||
|
||
SRC = $(SRC_DIR)/Server.cpp \ | ||
$(SRC_DIR)/ConfigManager.cpp $(SRC_DIR)/ConfigParser.cpp \ | ||
$(SRC_DIR)/Config.cpp $(SRC_DIR)/ConfigManager.cpp $(SRC_DIR)/ConfigParser.cpp \ | ||
$(SRC_DIR)/FileManager.cpp \ | ||
$(SRC_DIR)/ConnectionHandler.cpp \ | ||
$(SRC_DIR)/ConnectionHandler.cpp $(SRC_DIR)/CacheHandler.cpp \ | ||
$(SRC_DIR)/Worker.cpp \ | ||
$(SRC_DIR)/HTTPRequest.cpp $(SRC_DIR)/HTTPResponse.cpp $(SRC_DIR)/URI.cpp \ | ||
$(SRC_DIR)/CGIHandler.cpp $(SRC_DIR)/FileHandler.cpp \ | ||
|
@@ -59,14 +59,17 @@ $(OBJ_DIR)/%.o: %.cpp | |
$(CXX) $(CXXFLAGS) -c $< -o $@ | ||
|
||
debug: $(DEBUG_OBJ) | ||
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(DEBUG_OBJ) -o $(NAME) | ||
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(DEBUG_OBJ) -lpthread -o $(NAME) | ||
|
||
$(DEBUG_OBJ_DIR)/%.o: %.cpp | ||
@mkdir -p $(DEBUG_OBJ_DIR) | ||
$(CXX) $(CXXFLAGS) $(DEBUGFLAGS) -c $< -o $@ | ||
|
||
run: daemon | ||
$(MAKE) wait-for-healthy | ||
docker compose exec -it webserv make | ||
docker compose exec -it webserv bash -c "kill 1" | ||
sleep 1 | ||
@make logs | ||
|
||
daemon: | ||
|
@@ -78,13 +81,18 @@ watch: | |
inotifywait -qre close_write /app/src; \ | ||
done | ||
|
||
|
||
dev: | ||
export BUILD_TYPE=debug | ||
docker compose up --build -d webserv-dev | ||
docker compose exec -it webserv-dev make debug | ||
docker compose exec -it webserv-dev bash -c "./webserv" | ||
|
||
valgrind: | ||
export BUILD_TYPE=debug | ||
docker compose up --build -d webserv-dev | ||
docker compose exec -it webserv-dev make debug | ||
docker compose exec -it webserv-dev bash -c "ulimit -n 1024 && valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./webserv" | ||
|
||
logs: | ||
docker compose logs -f | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
server { | ||
listen 8080; | ||
server_name test.local; | ||
|
||
root /var/www/YoupiBanane; | ||
index index.html; | ||
# cgi on; | ||
|
||
location / { | ||
# autoindex on; | ||
limit_except GET { deny all; } | ||
} | ||
|
||
location /put_test/ { | ||
limit_except PUT { deny all; } | ||
} | ||
|
||
# location ~ \.bla$ { | ||
# limit_except POST { deny all; } | ||
# include /etc/nginx/fastcgi_params; | ||
# fastcgi_pass unix:/var/run/cgi_test.sock; | ||
# } | ||
|
||
location /post_body { | ||
limit_except POST { deny all; } | ||
client_max_body_size 100; | ||
} | ||
|
||
location /directory/ { | ||
limit_except GET { deny all; } | ||
autoindex on; | ||
index youpi.bad_extension; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
no loadbalancing: | ||
Lifting the server siege... | ||
Transactions: 106412 hits | ||
Availability: 100.00 % | ||
Elapsed time: 29.09 secs | ||
Data transferred: 70.53 MB | ||
Response time: 0.01 secs | ||
Transaction rate: 3658.03 trans/sec | ||
Throughput: 2.42 MB/sec | ||
Concurrency: 24.81 | ||
Successful transactions: 106413 | ||
Failed transactions: 0 | ||
Longest transaction: 0.03 | ||
Shortest transaction: 0.00 | ||
|
||
|
||
with loadbalancing (algo 1) | ||
Lifting the server siege... | ||
Transactions: 143922 hits | ||
Availability: 100.00 % | ||
Elapsed time: 29.32 secs | ||
Data transferred: 95.39 MB | ||
Response time: 0.01 secs | ||
Transaction rate: 4908.66 trans/sec | ||
Throughput: 3.25 MB/sec | ||
Concurrency: 24.69 | ||
Successful transactions: 143922 | ||
Failed transactions: 0 | ||
Longest transaction: 0.05 | ||
Shortest transaction: 0.00 | ||
|
||
with loadbalancing (algo 2) | ||
Lifting the server siege... | ||
Transactions: 231742 hits | ||
Availability: 100.00 % | ||
Elapsed time: 29.67 secs | ||
Data transferred: 153.60 MB | ||
Response time: 0.00 secs | ||
Transaction rate: 7810.65 trans/sec | ||
Throughput: 5.18 MB/sec | ||
Concurrency: 24.77 | ||
Successful transactions: 231742 | ||
Failed transactions: 0 | ||
Longest transaction: 0.06 | ||
Shortest transaction: 0.00 | ||
-------------------------------------- | ||
Lifting the server siege... | ||
Transactions: 111982 hits | ||
Availability: 100.00 % | ||
Elapsed time: 17.79 secs | ||
Data transferred: 74.22 MB | ||
Response time: 0.00 secs | ||
Transaction rate: 6294.66 trans/sec | ||
Throughput: 4.17 MB/sec | ||
Concurrency: 24.57 | ||
Successful transactions: 111983 | ||
Failed transactions: 0 | ||
Longest transaction: 0.03 | ||
Shortest transaction: 0.00 | ||
|
||
nginx: | ||
Lifting the server siege... | ||
Transactions: 458431 hits | ||
Availability: 100.00 % | ||
Elapsed time: 26.94 secs | ||
Data transferred: 303.85 MB | ||
Response time: 0.00 secs | ||
Transaction rate: 17016.74 trans/sec | ||
Throughput: 11.28 MB/sec | ||
Concurrency: 22.63 | ||
Successful transactions: 458437 | ||
Failed transactions: 0 | ||
Longest transaction: 0.09 | ||
Shortest transaction: 0.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Liste des IDs des workers qui ont démarré | ||
started_workers = [ | ||
1209762, 1209771, 1209764, 1209770, 1209766, 1209769, 1209767, 1209765, | ||
1209772, 1209768, 1209763, 1209773, 1209774, 1209775, 1209776, 1209777, | ||
1209778, 1209779, 1209780, 1209781 | ||
] | ||
|
||
# Liste des IDs des workers qui ont terminé | ||
finished_workers = [ | ||
1209772, 1209771, 1209764, 1209777, 1209769, 1209767, 1209762, 1209765, | ||
1209766, 1209781, 1209773, 1209776, 1209779, 1209763, 1209774, 1209780, | ||
1209775, 1209778, 1209770 | ||
] | ||
not_finished_workers = set(started_workers) - set(finished_workers) | ||
|
||
print("Workers qui n'ont pas terminé:", not_finished_workers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ server { | |
} | ||
|
||
location /cgi/ { | ||
autoindex on; | ||
cgi on; | ||
limit_except GET POST { deny all; } | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# NGINX Compatible conf (no cgi or upload) | ||
worker_processes auto; | ||
|
||
server { | ||
listen 8080; | ||
server_name example.co example.fr; | ||
|
||
# Default error pages | ||
# error_page 403 /errors/403.html; | ||
# error_page 500 /errors/500.html; | ||
error_page 404 /errors/404_main.html; | ||
|
||
# Client body size limit (in bytes) | ||
client_max_body_size 1048576; # 1MB | ||
|
||
# root /var/www/html; # Root directory for the server | ||
; root /home/mchenava/webserv/site; | ||
root /mnt/e/webserv/site; | ||
autoindex on; | ||
# index index.html; | ||
|
||
# Routes configuration | ||
location / { | ||
autoindex on; | ||
index i-index.html; # Default file if request is a directory | ||
limit_except GET POST { deny all; } # Allowed HTTP methods | ||
client_max_body_size 123; | ||
} | ||
|
||
location /dir/ { | ||
error_page 404 /errors/404_api.html; | ||
limit_except GET POST { deny all; } # Allowed HTTP methods | ||
} | ||
|
||
location /site/ { | ||
limit_except GET POST { deny all; } # Allowed HTTP methods | ||
} | ||
|
||
# location /upload/ { | ||
# limit_except POST { deny all; } # Allowed HTTP methods | ||
# accept_upload on; | ||
# } | ||
|
||
location /cgi/ { | ||
cgi on; | ||
limit_except GET POST { deny all; } # Allowed HTTP methods | ||
} | ||
|
||
location /cgi/off/ { | ||
cgi off; | ||
limit_except GET POST { deny all; } # Allowed HTTP methods | ||
} | ||
|
||
location /redirect/ { | ||
return 301 http://anotherdomain.com; | ||
return 200 blabla; # Should be ignored | ||
limit_except GET { deny all; } # Allowed HTTP methods | ||
} | ||
} | ||
|
||
# Additional server instance (example of multiple server configurations) | ||
server { | ||
listen 8081; | ||
server_name another.local; | ||
|
||
# Default error pages | ||
error_page 404 /errors/404.html; | ||
error_page 500 /errors/500.html; | ||
|
||
# Client body size limit (in bytes) | ||
client_max_body_size 2048000; # 2MB | ||
|
||
location /files/ { | ||
root /var/www/files; | ||
index index.html; | ||
limit_except GET POST { deny all; } | ||
autoindex off; | ||
} | ||
} |
Oops, something went wrong.