From 5c2cdc03b67d3040254719e8042c8066ef55523f Mon Sep 17 00:00:00 2001 From: Botis Date: Fri, 22 Nov 2024 16:36:23 +0100 Subject: [PATCH] Remove API_SERVER_NAME from compose files and some configs --- compose.connectors.yml | 2 +- compose.init_certs.yml | 3 - compose.override.yml | 6 +- compose.yml | 16 +-- docker/router/templates/default.conf.template | 125 +++++++++--------- 5 files changed, 73 insertions(+), 79 deletions(-) diff --git a/compose.connectors.yml b/compose.connectors.yml index a57dfb5ad..241415da1 100644 --- a/compose.connectors.yml +++ b/compose.connectors.yml @@ -3,7 +3,7 @@ services: networks: default: aliases: - - ${API_SERVER_NAME:-api.gally.localhost} + - ${SERVER_NAME:-gally.localhost} networks: default: diff --git a/compose.init_certs.yml b/compose.init_certs.yml index 8786ab5bf..f0c3884a2 100644 --- a/compose.init_certs.yml +++ b/compose.init_certs.yml @@ -9,7 +9,6 @@ services: - certbot_www:/var/www/certbot environment: - SERVER_NAME=${SERVER_NAME:-gally.localhost} - - API_SERVER_NAME=${API_SERVER_NAME:-api.gally.localhost} certbot_init_certs: build: @@ -19,8 +18,6 @@ services: - certbot_www:/var/www/certbot environment: - SERVER_NAME=${SERVER_NAME:-gally.localhost} - - API_SERVER_NAME=${API_SERVER_NAME:-api.gally.localhost} - - HAS_MULTIPLE_DOMAINS=${API_SERVER_NAME:-} volumes: certbot_www: diff --git a/compose.override.yml b/compose.override.yml index db928cdad..5ea6a7553 100644 --- a/compose.override.yml +++ b/compose.override.yml @@ -36,7 +36,7 @@ services: target: gally_pwa_dev args: - NEXT_PUBLIC_ENTRYPOINT=${SERVER_NAME:-gally.localhost} - - NEXT_PUBLIC_API_URL=https://${API_SERVER_NAME:-${SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - NEXT_PUBLIC_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} volumes: - ./front:/usr/src/front:rw,cached,z environment: @@ -51,12 +51,12 @@ services: additional_contexts: front_src: ./front args: - - REACT_APP_API_URL=https://${API_SERVER_NAME:-${SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - REACT_APP_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} volumes: - ./front:/usr/src/front:rw,cached,z environment: - PUBLIC_URL=https://${SERVER_NAME:-gally.localhost}/example - - REACT_APP_API_URL=https://${API_SERVER_NAME:-${SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - REACT_APP_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} ###> doctrine/doctrine-bundle ### database: diff --git a/compose.yml b/compose.yml index a7f8a7180..2c5da34a8 100644 --- a/compose.yml +++ b/compose.yml @@ -15,7 +15,6 @@ services: condition: service_healthy environment: - SERVER_NAME=${SERVER_NAME:-gally.localhost} - - API_SERVER_NAME=${API_SERVER_NAME:-api.gally.localhost} - BACKEND_UPSTREAM=varnish:80 certbot: @@ -25,8 +24,6 @@ services: - ./docker/certbot/certs:/etc/letsencrypt environment: - SERVER_NAME=${SERVER_NAME:-gally.localhost} - - API_SERVER_NAME=${API_SERVER_NAME:-api.gally.localhost} - - HAS_MULTIPLE_DOMAINS=${API_SERVER_NAME:-} varnish: build: @@ -49,7 +46,6 @@ services: - pwa environment: - SERVER_NAME=${SERVER_NAME:-gally.localhost} - - API_SERVER_NAME=${API_SERVER_NAME:-api.gally.localhost} - API_ROUTE_PREFIX=${API_ROUTE_PREFIX:-api} - PWA_UPSTREAM=${PWA_UPSTREAM:-pwa:3000} - API_UPSTREAM=${API_UPSTREAM:-php:9000} @@ -73,10 +69,10 @@ services: environment: - APP_ENV=${APP_ENV:-prod} - APP_SECRET=${APP_SECRET:-!ChangeMe!} - - SERVER_NAME=${SERVER_NAME:-${API_SERVER_NAME:-api.gally.localhost}}, php:80 + - SERVER_NAME=${SERVER_NAME:-gally.localhost}, php:80 - API_ROUTE_PREFIX=${API_ROUTE_PREFIX:-} - TRUSTED_PROXIES=${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16} - - TRUSTED_HOSTS=${TRUSTED_HOSTS:-^${SERVER_NAME:-|gally.localhost}|${API_SERVER_NAME:-|api.gally.localhost}|localhost|php$$} + - TRUSTED_HOSTS=${TRUSTED_HOSTS:-^${SERVER_NAME:-|gally.localhost}|localhost|php$$} - CORS_ALLOW_ORIGIN=^https?://${SERVER_NAME:-gally.localhost}$ - GALLY_CATALOG_MEDIA_URL=${GALLY_CATALOG_MEDIA_URL:-https://${SERVER_NAME:-gally.localhost}/media/catalog/product/} - DATABASE_URL=postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-16}&charset=${POSTGRES_CHARSET:-utf8} @@ -91,14 +87,14 @@ services: front_src: ./front args: - NEXT_PUBLIC_ENTRYPOINT=${SERVER_NAME:-gally.localhost} - - NEXT_PUBLIC_API_URL=https://${API_SERVER_NAME:-${SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - NEXT_PUBLIC_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} - NEXT_PUBLIC_API_ROUTE_PREFIX=${API_ROUTE_PREFIX:-} - - REACT_APP_API_URL=https://${SERVER_NAME:-${API_SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - REACT_APP_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} environment: - NEXT_PUBLIC_ENTRYPOINT=${SERVER_NAME:-gally.localhost} - - NEXT_PUBLIC_API_URL=https://${API_SERVER_NAME:-${SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - NEXT_PUBLIC_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} - NEXT_PUBLIC_API_ROUTE_PREFIX=${API_ROUTE_PREFIX:-} - - REACT_APP_API_URL=https://${API_SERVER_NAME:-${SERVER_NAME:-api.gally.localhost}}/${API_ROUTE_PREFIX:-} + - REACT_APP_API_URL=https://${SERVER_NAME:-gally.localhost}/${API_ROUTE_PREFIX:-} healthcheck: test: test $$(curl --connect-timeout 2 -s -o /dev/null -w ''%{http_code}'' http://localhost:3000) -eq 200 interval: 10s diff --git a/docker/router/templates/default.conf.template b/docker/router/templates/default.conf.template index 78e48d1fc..4f6bd5db2 100644 --- a/docker/router/templates/default.conf.template +++ b/docker/router/templates/default.conf.template @@ -2,69 +2,70 @@ upstream fastcgi_backend { server "$API_UPSTREAM"; } +# Comment this part because for the moment we don't manage a dedicated domain/subdomain for the API # Api specific domain routing -server { - server_name $API_SERVER_NAME; - root /app/public; - listen 80; - - client_body_buffer_size 4m; - client_max_body_size 256m; - fastcgi_buffers 64 16k; - fastcgi_buffer_size 64k; - - # Routage pour l'application API PHP basé sur le chemin ou le domaine - location / { - # Overwrite X-Forwarded-For with actual client IP - add_header X-Forwarded-For $remote_addr; - - # to let webapp know it's https traffic. - add_header X-Forwarded-Proto $scheme; - - try_files $uri /index.php$is_args$args; - } - - # Route toutes les requêtes vers l'application PHP API Platform pour $API_SERVER_NAME - location ~ ^/index\.php(/|$) { - - # when PHP-FPM is configured to use TCP - fastcgi_pass fastcgi_backend; - - fastcgi_split_path_info ^(.+\.php)(/.*)$; - include fastcgi_params; - - # optionally set the value of the environment variables used in the application - # fastcgi_param APP_ENV prod; - # fastcgi_param APP_SECRET ; - # fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"; - - # When you are using symlinks to link the document root to the - # current version of your application, you should pass the real - # application path instead of the path to the symlink to PHP - # FPM. - # Otherwise, PHP's OPcache may not properly detect changes to - # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 - # for more information). - # Caveat: When PHP-FPM is hosted on a different machine from nginx - # $realpath_root may not resolve as you expect! In this case try using - # $document_root instead. - fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; - fastcgi_param DOCUMENT_ROOT $realpath_root; - # Prevents URIs that include the front controller. This will 404: - # http://example.com/index.php/some-path - # Remove the internal directive to allow URIs like this - internal; - } - - # return 404 for all other php files not matching the front controller - # this prevents access to other php files you don't want to be accessible. - location ~ \.php$ { - return 404; - } - - access_log /dev/stdout main; - error_log /dev/stderr notice; -} +#server { +# server_name $API_SERVER_NAME; +# root /app/public; +# listen 80; +# +# client_body_buffer_size 4m; +# client_max_body_size 256m; +# fastcgi_buffers 64 16k; +# fastcgi_buffer_size 64k; +# +# # Routage pour l'application API PHP basé sur le chemin ou le domaine +# location / { +# # Overwrite X-Forwarded-For with actual client IP +# add_header X-Forwarded-For $remote_addr; +# +# # to let webapp know it's https traffic. +# add_header X-Forwarded-Proto $scheme; +# +# try_files $uri /index.php$is_args$args; +# } +# +# # Route toutes les requêtes vers l'application PHP API Platform pour $API_SERVER_NAME +# location ~ ^/index\.php(/|$) { +# +# # when PHP-FPM is configured to use TCP +# fastcgi_pass fastcgi_backend; +# +# fastcgi_split_path_info ^(.+\.php)(/.*)$; +# include fastcgi_params; +# +# # optionally set the value of the environment variables used in the application +# # fastcgi_param APP_ENV prod; +# # fastcgi_param APP_SECRET ; +# # fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name"; +# +# # When you are using symlinks to link the document root to the +# # current version of your application, you should pass the real +# # application path instead of the path to the symlink to PHP +# # FPM. +# # Otherwise, PHP's OPcache may not properly detect changes to +# # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 +# # for more information). +# # Caveat: When PHP-FPM is hosted on a different machine from nginx +# # $realpath_root may not resolve as you expect! In this case try using +# # $document_root instead. +# fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; +# fastcgi_param DOCUMENT_ROOT $realpath_root; +# # Prevents URIs that include the front controller. This will 404: +# # http://example.com/index.php/some-path +# # Remove the internal directive to allow URIs like this +# internal; +# } +# +# # return 404 for all other php files not matching the front controller +# # this prevents access to other php files you don't want to be accessible. +# location ~ \.php$ { +# return 404; +# } +# +# access_log /dev/stdout main; +# error_log /dev/stderr notice; +#} # Pwa and common domain name server {