couchbase-lite-core icon indicating copy to clipboard operation
couchbase-lite-core copied to clipboard

Replicator: HTTP/1.0 404 Not Found with Openshift and Port 443

Open florianfiby opened this issue 3 years ago • 9 comments

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

florianfiby avatar Aug 31 '22 15:08 florianfiby

What does Postman have this header as?

borrrden avatar Sep 01 '22 01:09 borrrden

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.

florianfiby avatar Sep 01 '22 06:09 florianfiby

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)

florianfiby avatar Sep 01 '22 08:09 florianfiby

Does this happen in plain installs as well, or just this particular setup?

borrrden avatar Sep 01 '22 22:09 borrrden

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.

florianfiby avatar Sep 02 '22 05:09 florianfiby

Seems like a change that would be easy enough to make, as long as Sync Gateway is not going to care either way.

borrrden avatar Sep 06 '22 02:09 borrrden

Migrated to CBL-3651

borrrden avatar Sep 06 '22 02:09 borrrden

Do you know, when this change will be solved?

florianfiby avatar Sep 08 '22 08:09 florianfiby

If you mean merged, probably sometime soon. If you mean released, that is TBD.

borrrden avatar Sep 08 '22 22:09 borrrden