You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A redirect from the "/" path to a different host that describes the project
The project's backend API under "/prefix"
Some static content (paths other than "/" or the API prefix.
I am adding a variant of "3" which is a virtual host for another name that will serve static content under a different directory based on the incoming "Host:" header. This works.
However, I'd prefer to not serve either the redirect or the API to requests for the alternative name. How can this be done?
This is currently served via the below, which is only host-specific for the static content. How would I restrict the redirect and the API to just the default vhost, with all other hosts seeing just the Files API (or perhaps some day a different host-specific router)?
P.S. I also didn't know how to reject malformed Host: headers with a 401 or suitable error code. So settled to just ignore them. Perhaps something I could do with RawM, but it is not immediately obvious how to use serveDirectoryWith as a handler for RawM.
The text was updated successfully, but these errors were encountered:
vdukhovni
changed the title
Question: How restrict an API to a particular virtual host (value of the request "Host:" header)?
Question: How to restrict an API to a particular virtual host (value of the request "Host:" header)?
Sep 11, 2023
Hmmm, it's an interesting problematic. I think my first reflex would be to do routing at the reverse proxy level (nginx, Apache, caddy, etc), and expose endpoints with specific audiences in mind.
My server hosts:
I am adding a variant of "3" which is a virtual host for another name that will serve static content under a different directory based on the incoming "Host:" header. This works.
However, I'd prefer to not serve either the redirect or the API to requests for the alternative name. How can this be done?
This is currently served via the below, which is only host-specific for the static content. How would I restrict the redirect and the API to just the default vhost, with all other hosts seeing just the
Files
API (or perhaps some day a different host-specific router)?P.S. I also didn't know how to reject malformed
Host:
headers with a401
or suitable error code. So settled to just ignore them. Perhaps something I could do withRawM
, but it is not immediately obvious how to useserveDirectoryWith
as a handler forRawM
.The text was updated successfully, but these errors were encountered: