kbase / service_wizard2

service_wizard2
MIT License
0 stars 0 forks source link

Change service URL based on request header "HOST" #19

Open bio-boris opened 8 months ago

bio-boris commented 8 months ago

Request at staging.kbase.us

curl -s -d  '{"params":["JobBrowser"],"method":"ServiceWizard.list_service_status","version":"1.1","id":1}'  https://staging.kbase.us/services/service_wizard

Query: Headers {host = ''} Response

{ url=staging.kbase.us/dynamic_services/JobBrowser }

Query: Headers {host = 'staging2.kbase.us'} Response

{ url=staging2.kbase.us/dynamic_services/JobBrowser}

Request at staging2.kbase.us

curl -s -d  '{"params":["JobBrowser"],"method":"ServiceWizard.list_service_status","version":"1.1","id":1}'  https://staging2.kbase.us/services/service_wizard

Query: Headers {host = ''} Response

{ url=staging2.kbase.us/dynamic_services/JobBrowser }

Query: Headers {host = 'staging3.kbase.us'} Response

{ url=staging3.kbase.us/dynamic_services/JobBrowser}
eapearson commented 8 months ago

@bio-boris I think that is basically correct (although each url should include the protocol https://, but I'm sure you just begin brief, which I just spoiled.)

I'm not sure there is a valid case for the host being empty, though.

The host name for the initial request needs to be propagated by each proxy between the original client request and the upstream service.

The host should be available in the Host header, and available in nginx with the $http_host or $http nginx variables. They are similar but different.

bio-boris commented 8 months ago

Hmm, maybe I will add a README section about how SW2 needs to run behind a proxy and the headers

and this needs to match config values of allowed subdomains or else it will throw an error that that subdomain is not allowed.