Skip to content

Commit

Permalink
Remove API_SERVER_NAME from compose files and some configs
Browse files Browse the repository at this point in the history
  • Loading branch information
botisSmile committed Nov 26, 2024
1 parent 27f87b9 commit 5c2cdc0
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 79 deletions.
2 changes: 1 addition & 1 deletion compose.connectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
networks:
default:
aliases:
- ${API_SERVER_NAME:-api.gally.localhost}
- ${SERVER_NAME:-gally.localhost}

networks:
default:
Expand Down
3 changes: 0 additions & 3 deletions compose.init_certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
6 changes: 3 additions & 3 deletions compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
16 changes: 6 additions & 10 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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
Expand Down
125 changes: 63 additions & 62 deletions docker/router/templates/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app-secret-id>;
# 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 <app-secret-id>;
# # 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 {
Expand Down

0 comments on commit 5c2cdc0

Please sign in to comment.