From 2c3c6aa50ff542c6e3dc25fc28805bceff512ae7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 5 Jul 2025 16:25:14 +0000 Subject: [PATCH] s'occuper de worDdpress --- srcs/docker-compose.yml | 122 ++++++++++++------------ srcs/requirements/nginx/Dockerfile | 6 +- srcs/requirements/nginx/conf/nginx.conf | 107 ++++----------------- srcs/requirements/nginx/tools/run.sh | 26 +++++ 4 files changed, 111 insertions(+), 150 deletions(-) create mode 100644 srcs/requirements/nginx/tools/run.sh diff --git a/srcs/docker-compose.yml b/srcs/docker-compose.yml index 6be5682..636ea71 100644 --- a/srcs/docker-compose.yml +++ b/srcs/docker-compose.yml @@ -1,65 +1,67 @@ -services: - mariadb: - container_name: mariadb - networks: - - inception - build: - context: ./requirements/mariadb - dockerfile: Dockerfile - env_file: .env - volumes: - - mariadb:/var/lib/mysql - restart: unless-stopped - expose: - - "3306" + version: "3" - nginx: - container_name: nginx - volumes: - - wordpress:/var/www/wordpress - networks: - - inception - depends_on: - - wordpress - build: - context: ./requirements/nginx - dockerfile: Dockerfile - env_file: .env - ports: - - "443:443" - restart: on-failure + services: + nginx: + container_name: nginx + volumes: + - wordpress:/var/www/wordpress + networks: + - inception + depends_on: + - wordpress + build: + context: ./requirements/nginx + dockerfile: Dockerfile + env_file: .env + ports: + - "443:443" + restart: always - wordpress: - container_name: wordpress - env_file: .env - volumes: - - wordpress:/var/www/wordpress - networks: - - inception - build: - context: ./requirements/wordpress - dockerfile: Dockerfile - depends_on: - - mariadb - restart: on-failure - expose: - - "9000" + wordpress: + container_name: wordpress + env_file: .env + volumes: + - wordpress:/var/www/wordpress + networks: + - inception + build: + context: ./requirements/wordpress + dockerfile: Dockerfile + depends_on: + - mariadb + restart: always + expose: + - "9000" -volumes: - wordpress: - driver: local - driver_opts: - type: 'none' - o: 'bind' - device: '/home/yantoine/data/wordpress' - mariadb: - driver: local - driver_opts: - type: 'none' - o: 'bind' - device: '/home/yantoine/data/mariadb' + mariadb: + container_name: mariadb + networks: + - inception + build: + context: ./requirements/mariadb + dockerfile: Dockerfile + env_file: .env + volumes: + - mariadb:/var/lib/mysql + restart: always + expose: + - "3306" -networks: - inception: - driver: bridge + volumes: + wordpress: + name: wordpress + driver: local + driver_opts: + type: none + o: bind + device: /home/yantoine/data/wordpress + mariadb: + driver: local + driver_opts: + type: none + o: bind + device: /home/yantoine/data/mariadb + networks: + inception: + driver: bridge diff --git a/srcs/requirements/nginx/Dockerfile b/srcs/requirements/nginx/Dockerfile index a5a445a..f9b9da2 100644 --- a/srcs/requirements/nginx/Dockerfile +++ b/srcs/requirements/nginx/Dockerfile @@ -2,8 +2,6 @@ FROM debian:bullseye RUN apt update -y RUN apt upgrade -y RUN apt install nginx -y -RUN apt install vim -y -RUN apt install curl -y RUN apt install openssl -y RUN mkdir -p /etc/nginx/ssl RUN mkdir -p /var/run/nginx @@ -11,4 +9,6 @@ RUN openssl req -x509 -nodes -out /etc/nginx/ssl/inception.crt -keyout /etc/ngin COPY conf/nginx.conf /etc/nginx/nginx.conf RUN chmod 755 /var/www/html RUN chown -R www-data:www-data /var/www/html -ENTRYPOINT [ "nginx", "-g", "daemon off;" ] \ No newline at end of file +COPY ./tools/run.sh /run.sh +RUN chmod +x /run.sh +ENTRYPOINT ["/run.sh"] diff --git a/srcs/requirements/nginx/conf/nginx.conf b/srcs/requirements/nginx/conf/nginx.conf index 1477f5c..4504243 100644 --- a/srcs/requirements/nginx/conf/nginx.conf +++ b/srcs/requirements/nginx/conf/nginx.conf @@ -1,92 +1,25 @@ +server { + #SSL/TLS Configuration + listen 443 ssl; + listen [::]:443 ssl; + ssl_protocols TLSv1.3; + ssl_certificate /etc/nginx/ssl/inception.crt; + ssl_certificate_key /etc/nginx/ssl/inception.key; - -user www-data; -worker_processes auto; -pid /run/nginx.pid; -include /etc/nginx/modules-enabled/*.conf; - -events { - worker_connections 768; - # multi_accept on; -} - -http { - ## - # Basic Settings - ## - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - # server_tokens off; - - # server_names_hash_bucket_size 64; - # server_name_in_redirect off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - ## - # SSL Settings - ## - - ssl_prefer_server_ciphers on; - - ## - # Logging Settings - ## - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; - - ## - # Virtual Host Configs - ## - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; - - server { - #SSL/TLS Configuration - listen 443 ssl; - ssl_protocols TLSv1.2 TLSv1.3; - ssl_certificate /etc/nginx/ssl/inception.crt; - ssl_certificate_key /etc/nginx/ssl/inception.key; - - #root and index and server_name - root /var/www/html; - server_name yantoine.42.fr; - #index; - index index.php index.html index.htm; - - location / { - try_files $uri $uri/ =404; - } - - # Pour toutes les requetes php - location ~ \.php$ { - fastcgi_pass wordpress:9000; + #root and index and server_name + root /var/www/html; + server_name yantoine.42.fr; + #index; + index index.php + + # Pour toutes les requetes php + location ~ [^/]\.php(/|$) { + try_files $uri =404; + fastcgi_pass wordpress:9000; include snippets/fastcgi-php.conf; - #fastcgi_index index.php; - #include fastcgi_params; - #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - #fastcgi_param PATH_INFO $fastcgi_path_info; - } + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } } } diff --git a/srcs/requirements/nginx/tools/run.sh b/srcs/requirements/nginx/tools/run.sh new file mode 100644 index 0000000..4d74138 --- /dev/null +++ b/srcs/requirements/nginx/tools/run.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +echo " +server { + listen 443 ssl; + listen [::]:443 ssl; + #server_name yantoine.42.fr + ssl_certificate /etc/nginx/ssl/inception.crt; + ssl_certificate_key /etc/nginx/ssl/inception.key;" > /etc/nginx/sites-available/default + + +echo ' + ssl_protocols TLSv1.3; + index index.php + root /var/www/html; + + location ~ [^/]\.php(/|$) { + try_files $uri =404; + fastcgi_pass wordpress:9000; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } +} ' >> /etc/nginx/sites-available/default + + +nginx -g "daemon off;"