From 7c9e0028544333d3c7f7a3e3225e8040f1480db4 Mon Sep 17 00:00:00 2001 From: Sehyun Hwang Date: Sun, 10 Sep 2023 14:19:32 +0000 Subject: [PATCH] Resolve cors configuration in fly --- docker-compose.yml | 6 ++++++ fly.toml | 8 ++++++-- nginx/fly.toml | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 nginx/fly.toml diff --git a/docker-compose.yml b/docker-compose.yml index 71c9e34..9c63020 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,12 @@ services: stream: image: ${CONTAINER_REGISTRY-ghcr.io/sehyun-hwang}/imshow-nginx:${TAG:-latest} build: nginx + command: + - sh + - -c + - > + sed -i 's/listen 80/listen 80;listen [::]:80/' /etc/nginx/nginx.conf + && /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf depends_on: - express ports: diff --git a/fly.toml b/fly.toml index 6b4e13a..f26757b 100644 --- a/fly.toml +++ b/fly.toml @@ -5,19 +5,19 @@ kill_signal = "SIGINT" kill_timeout = 5 primary_region = "nrt" -http_options = { response = { headers = { "Access-Control-Allow-Origin" = "https://sehyun-hwang.github.io" } } } [build] image = "ghcr.io/sehyun-hwang/imshow-express:fly-initial" [env] - NGINX_HOST = imshow-nginx.internal + NGINX_HOST = "imshow-nginx.internal" [[services]] protocol = "tcp" internal_port = 80 processes = ["app"] + [[services.ports]] port = 80 handlers = ["http"] @@ -26,7 +26,11 @@ http_options = { response = { headers = { "Access-Control-Allow-Origin" = "https [[services.ports]] port = 443 handlers = ["tls", "http"] + [services.concurrency] type = "connections" hard_limit = 25 soft_limit = 20 + +[services.ports.http_options.response.headers] + Access-Control-Allow-Origin = "https://sehyun-hwang.github.io" diff --git a/nginx/fly.toml b/nginx/fly.toml new file mode 100644 index 0000000..c2c0a34 --- /dev/null +++ b/nginx/fly.toml @@ -0,0 +1,22 @@ +# fly.toml app configuration file generated for imshow-nginx on 2023-08-07T15:21:45Z +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = "imshow-nginx" +primary_region = "nrt" + +[build] + image = "shurco/nginx-push-stream-module" + +[http_service] + internal_port = 80 + force_https = true + auto_stop_machines = true + auto_start_machines = true + min_machines_running = 0 + processes = ["app"] + + +[experimental] +cmd = [ "sh", "-c", "sed -i 's/listen 80/listen 80;listen [::]:80/' /etc/nginx/nginx.conf && /usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf" ] \ No newline at end of file