From 702936a0569257c2e5368f9aef5344524d6c1bdd Mon Sep 17 00:00:00 2001
From: Etienne Loupias <eloupias@grandlyon.com>
Date: Fri, 21 Mar 2025 10:17:45 +0100
Subject: [PATCH] location /shared/jeuAieAieIA

---
 Dockerfile                            |  5 ---
 nginx/nginx.conf                      | 55 ---------------------------
 nginx/templates/default.conf.template | 18 +++++++++
 3 files changed, 18 insertions(+), 60 deletions(-)
 delete mode 100644 nginx/nginx.conf

diff --git a/Dockerfile b/Dockerfile
index 00a084e7a..daf06e71e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,7 +16,6 @@ COPY angular.json .
 COPY tsconfig.json .
 COPY tsconfig.app.json .
 COPY ngsw-config.json .
-COPY /nginx/nginx.conf .
 COPY /src ./src
 
 ARG conf
@@ -27,10 +26,6 @@ RUN npm run build:prod
 # Stage 1, based on Nginx, to have only the compiled app
 FROM ${DEPENDENCY_PROXY}nginxinc/nginx-unprivileged:1.25
 
-# Copy custom conf to write logs into file to persist them
-COPY nginx/nginx.conf /etc/nginx/nginx.conf
-RUN mkdir -p /tmp/log && chmod a+w /tmp/log
-
 # Copy nginx modified conf with template (cf. "Using environment variables in nginx configuration" in https://hub.docker.com/_/nginx )
 COPY nginx/templates/default.conf.template /etc/nginx/templates/default.conf.template
 
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
deleted file mode 100644
index 229a30885..000000000
--- a/nginx/nginx.conf
+++ /dev/null
@@ -1,55 +0,0 @@
-worker_processes  auto;
-
-error_log  /var/log/nginx/error.log notice;
-pid        /tmp/nginx.pid;
-
-
-events {
-    worker_connections  1024;
-}
-
-
-http {
-    proxy_temp_path /tmp/proxy_temp;
-    client_body_temp_path /tmp/client_temp;
-    fastcgi_temp_path /tmp/fastcgi_temp;
-    uwsgi_temp_path /tmp/uwsgi_temp;
-    scgi_temp_path /tmp/scgi_temp;
-
-    include       /etc/nginx/mime.types;
-    default_type  application/octet-stream;
-
-    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
-                      '$status $body_bytes_sent "$http_referer" '
-                      '"$http_user_agent" "$http_x_forwarded_for"';
-
-    map $time_iso8601 $year {
-        default '0000';
-        "~^(\d{4})-(\d{2})-(\d{2})" $1;
-    }
-    map $time_iso8601 $month {
-        default '00';
-        "~^(\d{4})-(\d{2})-(\d{2})" $2;
-    }
-    map $time_iso8601 $day {
-        default '00';
-        "~^(\d{4})-(\d{2})-(\d{2})" $3;
-    }
-
-    # Default log which is redirected to stdout
-    access_log  /var/log/nginx/access.log  main;
-    # Also write to file to persist logs
-    access_log  /tmp/log/access.$year-$month-$day.log  main;
-
-    sendfile        on;
-    #tcp_nopush     on;
-
-    keepalive_timeout  65;
-
-    #gzip  on;
-
-    include /etc/nginx/conf.d/*.conf;
-
-    # Max Body Size
-    client_max_body_size 10M;
-}
\ No newline at end of file
diff --git a/nginx/templates/default.conf.template b/nginx/templates/default.conf.template
index cec97a3a3..39ebd03b1 100644
--- a/nginx/templates/default.conf.template
+++ b/nginx/templates/default.conf.template
@@ -23,6 +23,19 @@ map $http_user_agent $prerender {
   "~*discordbot"                          1;
 }
 
+map $time_iso8601 $year {
+    default '0000';
+    "~^(\d{4})-(\d{2})-(\d{2})" $1;
+}
+map $time_iso8601 $month {
+    default '00';
+    "~^(\d{4})-(\d{2})-(\d{2})" $2;
+}
+map $time_iso8601 $day {
+    default '00';
+    "~^(\d{4})-(\d{2})-(\d{2})" $3;
+}
+
 server {
   listen 8080 default_server;
 
@@ -42,6 +55,11 @@ server {
     proxy_pass https://data.grandlyon.com/fr/datapusher/ws/grandlyon/adr_voie_lieu.adrcomgl/all.json;
   }
 
+  # Persist logs to a daily file
+  location /shared/jeuAieAieIA {
+      access_log /usr/share/nginx/html/shared/jeuAieAieIA/stats/log/access.$year-$month-$day.log  main;
+  }
+
   location / {
     add_header X-Frame-Options SAMEORIGIN always;
     add_header X-Content-Type-Options nosniff;
-- 
GitLab