diff --git a/Dockerfile b/Dockerfile index 00a084e7ad14d21b61aa32b46389f682610fb085..daf06e71e0aa4dbed65e7543bfb95311072c4dd5 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 229a30885508f07be521372bc74e1c720cb8f2f6..0000000000000000000000000000000000000000 --- 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 cec97a3a388b4c69569117c54228a8abc92c1bc2..39ebd03b1bf2664f68c73400405bba821f08eb6b 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;