From 0a877b2ac25e8cbc6232da5bcecdcc0b64e92b03 Mon Sep 17 00:00:00 2001
From: Sebastian <sebastian.karius@informatik.uni-halle.de>
Date: Tue, 29 Oct 2024 10:29:14 +0100
Subject: [PATCH] add nginx-cors

---
 .gitlab-ci.yml                        |  4 ++--
 docker-compose.yml                    |  4 ++--
 docker/nginx-cors/Dockerfile          |  2 +-
 docker/nginx-cors/nginx.conf.template | 26 ++------------------------
 helm/nginx-cors/Chart.yaml            |  4 ++--
 5 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 188436f..f810c17 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,7 +45,7 @@ helm-package:
       - vdo-ninja-0.1.2.tgz
       - ti-coder-0.2.6.tgz
       - ti-lamp-0.1.2.tgz
-      - nginx-cors-0.1.1.tgz
+      - nginx-cors-0.1.2.tgz
     expire_in: 1 hour
 
 helm-publish:
@@ -62,7 +62,7 @@ helm-publish:
     - 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@vdo-ninja-0.1.2.tgz" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"'
     - 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@ti-coder-0.2.6.tgz" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"'
     - 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@ti-lamp-0.1.2.tgz" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"'
-    - 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@nginx-cors-0.1.1.tgz" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"'
+    - 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@nginx-cors-0.1.2.tgz" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/stable/charts"'
 
 stages:
   - build
diff --git a/docker-compose.yml b/docker-compose.yml
index 9ef1b39..8ed8c69 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -40,9 +40,9 @@ services:
         - ${CI_REGISTRY}/studio-r215/containerize/php-fpm:83
 
   nginx-cors:
-    image: ${CI_REGISTRY}/studio-r215/containerize/nginx-cors:1.0.1
+    image: ${CI_REGISTRY}/studio-r215/containerize/nginx-cors:1.0.2
     build:
       dockerfile: Dockerfile
       context: ./docker/nginx-cors
       cache_from:
-        - ${CI_REGISTRY}/studio-r215/containerize/nginx-cors:1.0.1
\ No newline at end of file
+        - ${CI_REGISTRY}/studio-r215/containerize/nginx-cors:1.0.2
\ No newline at end of file
diff --git a/docker/nginx-cors/Dockerfile b/docker/nginx-cors/Dockerfile
index d24c8af..95e418a 100644
--- a/docker/nginx-cors/Dockerfile
+++ b/docker/nginx-cors/Dockerfile
@@ -2,4 +2,4 @@ FROM nginx:alpine
 
 WORKDIR /etc/nginx
 COPY nginx.conf.template nginx.conf.template
-CMD [ "/bin/sh" , "-c" , "envsubst < nginx.conf.template > /etc/nginx/conf.d/nginx.conf && exec nginx -g 'daemon off;'" ]
\ No newline at end of file
+CMD [ "/bin/sh" , "-c" , "envsubst < nginx.conf.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" ]
\ No newline at end of file
diff --git a/docker/nginx-cors/nginx.conf.template b/docker/nginx-cors/nginx.conf.template
index 9bc5913..7103d91 100644
--- a/docker/nginx-cors/nginx.conf.template
+++ b/docker/nginx-cors/nginx.conf.template
@@ -1,31 +1,9 @@
-upstream api {
-  # Could be host.docker.internal - Docker for Mac/Windows - the host itself
-  # Could be your API in a appropriate domain
-  # Could be other container in the same network, like container_name:port
-  server ${API_URL};
-}
-
 server {
   listen 80;
-  server_name localhost;
-
   location / {
-    #if ($request_method = OPTIONS) {
-    #  add_header 'Access-Control-Max-Age' 1728000;
-    #  add_header 'Access-Control-Allow-Origin' '*';
-    #  add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,
-    #  X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
-    #  add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
-    #  add_header 'Content-Type' 'application/json';
-    #  add_header 'Content-Length' 0;
-    #  return 204;
-    #}
-
     add_header 'Access-Control-Allow-Origin' '*';
-    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,
-    X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
+    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
     add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
-
-    proxy_pass http://api;
+    proxy_pass 'https://${API_URL}/';
   }
 }
\ No newline at end of file
diff --git a/helm/nginx-cors/Chart.yaml b/helm/nginx-cors/Chart.yaml
index 9f144f5..9d21d1c 100644
--- a/helm/nginx-cors/Chart.yaml
+++ b/helm/nginx-cors/Chart.yaml
@@ -15,10 +15,10 @@ type: application
 # This is the chart version. This version number should be incremented each time you make changes
 # to the chart and its templates, including the app version.
 # Versions are expected to follow Semantic Versioning (https://semver.org/)
-version: 0.1.1
+version: 0.1.2
 
 # This is the version number of the application being deployed. This version number should be
 # incremented each time you make changes to the application. Versions are not expected to
 # follow Semantic Versioning. They should reflect the version the application is using.
 # It is recommended to use it with quotes.
-appVersion: "1.0.1"
+appVersion: "1.0.2"
-- 
GitLab