diff --git a/docker-compose.example.yml b/docker-compose.example.yml index f50e12e..40394dd 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -52,6 +52,8 @@ services: FPM_ROOT: $PWD/pub MAGE_RUN_TYPE: store #or set to website command: /bin/sh -c "envsubst '$$MAGE_RUN_TYPE $$FPM_PORT $$FPM_XDEBUG $$FPM_ROOT $$FPM_ROOT_ABS' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'" + extra_hosts: + - "host.docker.internal:host-gateway" # Uncomment the ngrok service to expose your local environment online through ngrok # Adding your authtoken will grant you access to more features and longer session times. diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf index 110f979..a8f94d5 100644 --- a/nginx/conf.d/default.conf +++ b/nginx/conf.d/default.conf @@ -1,7 +1,20 @@ resolver 127.0.0.11 ipv6=off; + +# Define upstreams. +# These resolve at STARTUP, so they will read the /etc/hosts file +# generated by 'extra_hosts' on Linux. +upstream php_normal { + server host.docker.internal:${FPM_PORT}; +} + +upstream php_debug { + server host.docker.internal:${FPM_XDEBUG}; +} + +# Map the cookie to the UPSTREAM NAME, not the hostname map $cookie_XDEBUG_SESSION $phpfpm_backend { - "" host.docker.internal:${FPM_PORT}; - default host.docker.internal:${FPM_XDEBUG}; + "" php_normal; + default php_debug; } server {