Closed athiffau closed 9 months ago
This is by design. This is done to prevent apps to overwrite Cosmos' endpoint into phishing pages to steal credentials and cannot be solved. If you want to access a Cosmos instance from another one, the only solution is Constellation
What happened?
I am trying to chain two level of proxy using Cosmos but I get a StatusBadRequest (400) when the /cosmos/api/me end-point is loaded
What should have happened?
It should load the endpoint on the second layer instead of the first layer.
How to reproduce the bug?
I've been working on trying to chain two layers of proxy using Cosmos for a few days without success so I started to step through the code and this is why I think it currently cannot work. I'm not sure how to report this so hopefully this makes sense.
On xxx.xxx.xxx.193 I have a ubuntu server + cosmos installed = first layer I have the hostname of the first layer set to mydomain.com [internal IP xxx.xxx.xxx.193] *.mydomain.com is pointing to [public ip] -> OPNSense firewall -> xxx.xxx.xxx.193 mydomain has wildcard SSL with DNS challenge setup = working perfectly. I have a bunch of apps running on app[x].mydomain.com = working perfectly; note that some are in docker containers but some are proxied to external, standalone boxes. One example is HomeAssitant [Internal IP xxx.xxx.xxx.164] = working perfectly I create a proxy url as devbox.mydomain.com with target set to http://xxx.xxx.xxx.106
On xxx.xxx.xxx.106 I have a ubuntu server + cosmos installed = second layer SSL is disabled on the dev box. hostname is set to devbox.mydomain.com
I launch the url
devbox.mydomain.com
and this is what I see:api/me
end-pointFrom what I can tell, cosmos running in layer 1 starts parsing the url and run its checks and compares 'mydomain.com' to 'devbox.mydomain.com' which results in an invalid hostname. I think it's due to the redirect.
The solution is maybe to change function
EnsureHostnameCosmosAPI
[middleware.go] to evaluate all proxied hostnames as well - similar to what is done in functionEnsureHostname
[middleware.go]Relevant log output
No response
Other details
No response
System details