Ask HN: Help with Nginx Internal Redirect Based on Subdomain Validation I'm trying to set up an NGINX server block to handle requests based on subdomain validation. Here’s what I’m aiming for: Incoming Request: A request comes in with a subdomain (e.g., jiffy.example.com). Validation: The subdomain gets validated by my backend API which is an upstream server(http://backend_api/api/user/validate/$subdomain). The API responds: 200 OK if the subdomain is valid. 404 Not Found if the subdomain is invalid. Internal Redirects: Based on the API response, NGINX should: Route valid subdomains to a @userPage location (proxying to a userPage service). Route invalid subdomains to a @not_found location (proxying to a custom "not found" page). Here's what I have so far: ``` server { listen 443 ssl; server_name ~^(?<subdomain>.+)\.${USERPAGE_SERVER_NAME}$;
```What am i doing wrong here? I read about X-Accel-Redirect flag but I am not able to understand how to capture that flag in the response header if I send it as a response header from my api? Any help would be appreciated. |