# Default server block to catch all other requests server { listen 80; server_name _; # Wildcard server name to catch all requests # Return a 404 Forbidden error for any unmatched server_name location / { return 404 '{"status": 404, "message": "No cluster found for subdomain provided"}'; add_header Content-Type application/json; } } server { listen 80; server_name context.localhost; error_page 502 503 504 @custom_error; proxy_intercept_errors on; set $original_uri $request_uri; # Custom error handling location location @custom_error { internal; # You can use more variables here to make the error message more informative return 200 '{"status": "$status", "message": "Error occurred", "inbound_url": "$original_uri", "attempted_url": "$attempted_url", "proxy": "host-wide-local-proxy"}'; add_header Content-Type application/json; } location / { set $attempted_url http://monorepo-context-internal-proxy-1:80; proxy_pass $attempted_url; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } # Default server block to catch all other requests server { listen 80; server_name _; # Wildcard server name to catch all requests # Return a 404 Forbidden error for any unmatched server_name location / { return 404 '{"status": 404, "message": "No cluster found for subdomain provided"}'; add_header Content-Type application/json; } } server { listen 80; server_name bootstrap.localhost; error_page 502 503 504 @custom_error; proxy_intercept_errors on; set $original_uri $request_uri; # Custom error handling location location @custom_error { internal; # You can use more variables here to make the error message more informative return 200 '{"status": "$status", "message": "Error occurred", "inbound_url": "$original_uri", "attempted_url": "$attempted_url", "proxy": "host-wide-local-proxy"}'; add_header Content-Type application/json; } location / { set $attempted_url http://template-bootstrap-monorepo-internal-proxy-1:80; proxy_pass $attempted_url; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }