server { listen ${LISTEN_PORT}; server_name _; resolver 127.0.0.11 valid=1s; location / { proxy_pass http://${CONTAINER_PREFIX}-$http_x_forwarded_preferred_username:${CONTAINER_PORT}$uri; error_page 502 = @spawner; } location @spawner { proxy_pass ${SPAWNER_URL}$uri; } }