Ajout d'une partie du TP4

This commit is contained in:
2024-03-17 11:31:57 +01:00
commit 915052df70
9 changed files with 396 additions and 0 deletions

54
TP4/docker-compose.yml Normal file
View File

@@ -0,0 +1,54 @@
services:
redis:
image: redis/redis-stack
ports:
- "6379:6379"
volumes:
- redis_data:/data
restart: always
networks:
- back
redisinsight:
image: redis/redisinsight
ports:
- "5540:5540"
restart: always
volumes:
- redisinsight_data:/db
networks:
- back
php:
image: windok/php-redis
restart: always
volumes:
- ./web:/usr/share/nginx/html
environment:
NOM : "moguljak"
PRENOM : "tom"
deploy:
replicas: 2
networks:
- front
- back
nginx :
image: nginx
restart: always
ports:
- "80:80"
- "443:443"
volumes:
- ./web:/usr/share/nginx/html
- ./nginx:/etc/nginx/conf.d
networks:
- front
networks:
front:
back:
volumes:
redis_data:
redisinsight_data:

14
TP4/nginx/default.conf Normal file
View File

@@ -0,0 +1,14 @@
server {
server_name tp4.iut.fr;
listen 80;
root /usr/share/nginx/html;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

27
TP4/web/index.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
$redis = new Redis();
$redis->connect('tp4-redis-1', 6379);
$code = $redis->get('code');
echo "
<table>
<tr>
<td>SERVERNAME</td>
<td><b>".$_SERVER['SERVER_NAME']."</b></td>
</tr>
<tr>
<td>HOSTNAME</td>
<td><b>".gethostname()."</b></td>
</tr>
<tr>
<td>ETUDIANT</td>
<td><b>".$_ENV['NOM']." / ".$_ENV['PRENOM']."</b></td>
</tr>
<tr>
<td>CODE</td>
<td><b>$code</b></td>
</tr>
</table>";