couchbase-lite-core
couchbase-lite-core copied to clipboard
Replicator: HTTP/1.0 404 Not Found with Openshift and Port 443
When using SyncGateway on Openshift with Route on Standard Port (443) there is 404 Not Found while starting die Replicator. Problem is the port on the Header "Host: xxx:443".
Sending request to [https:/xxxx:443/yyy/_blipsync
GET /yyy/_blipsync HTTP/1.1
Host: myhost:443
Cookie: SyncGatewaySession=***
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: ****
Sec-WebSocket-Protocol: BLIP_3+CBMobile_3,BLIP_3+CBMobile_2
Got response:
HTTP/1.0 404 Not Found
Connection: close
Content-Length: 9
Same request is working on Postman.
I think I've found the issue in Networking/HTTP/HTTPLogic.cc:
"Host: " << string(slice(_address.hostname)) << ':' << _address.port << "\r\n";
I've found this issue using flutter https://github.com/cbl-dart/cbl-dart/tree/main/packages/cbl_ffi
What does Postman have this header as?
I've sent exactly the same request, but changed HOST to "Host: myhost" as the service is running on 443 standard port. I think the openshift reverse proxy is not able to route the request when sending the Host header with a default port included.
I was able to build couchbase-lite-C and modified Networking/HTTP/HTTPLogic.cc for testing. Now I was able to connect the syncgateway
diff --git a/Networking/HTTP/HTTPLogic.cc b/Networking/HTTP/HTTPLogic.cc
index 9257dac4..fac64bc5 100644
--- a/Networking/HTTP/HTTPLogic.cc
+++ b/Networking/HTTP/HTTPLogic.cc
@@ -108,7 +108,7 @@ namespace litecore { namespace net {
rq << string(slice(_address.path));
}
rq << " HTTP/1.1\r\n"
- "Host: " << string(slice(_address.hostname)) << ':' << _address.port << "\r\n";
+ "Host: " << string(slice(_address.hostname)) << "\r\n";
addHeader(rq, "User-Agent", _userAgent);
if (_proxy && _proxy->username)
Does this happen in plain installs as well, or just this particular setup?
Well I cant say that, cause it's a client side setup and I don't know the history. I think openshift uses haproxy with templates and the routing is not working with a port included in the http host header.
But as far, as I found informations about http rfc the port information inside Host Header is optional, and every modern browser is just sending it on non standard ports.
Seems like a change that would be easy enough to make, as long as Sync Gateway is not going to care either way.
Migrated to CBL-3651
Do you know, when this change will be solved?
If you mean merged, probably sometime soon. If you mean released, that is TBD.