Prevent bulk post in couchbase lite

Hello everyone,

I need some guidance on the following problem.

I need to replicate a number of documents, 10 to 100 documents(depends), 500K each document. Sync gateway sits behind nginx acting as reverse proxy. The error I get from nginx is Entity too large when I try to bulk upload all document.

Now the obvious solution is to modify nginx configuration to allow for such request size. But I would like to avoid that seeing it as a potential vulnerability allowing someone to make such big requests.

Another solution could be to replicate the single document when it is created but in case the user is offline for sometime i am back to the original problem having to replicate multiple documents at once.

I though to find a way to force the replication not to use bulk post but instead replicate each document one by one.

My questions

  1. Is this a good idea in general? How would it affect performance?

  2. Is at all possible to force such behaviour on the replication? Prevent bulk post and replicate one by one? I haven’t found anything related to that. Should I avoid the sync gateway and go directly to couchbase and post my documents one by one? How would that work?

Thank you for your time

Is at all possible to force such behaviour on the replication?

No, it’s not configurable to that degree. You’ll need to configure your nginx to allow larger requests, at least for URLs with bulk_docs in the path.

Should I avoid the sync gateway and go directly to couchbase

You can’t do that — Couchbase Server should not be directly reachable from the public Internet. It should sit behind your firewall. (Even if you could reach it, writing directly into Sync Gateway’s bucket isn’t allowed, because the document metadata won’t be updated correctly.)

Hi Jens. Thank you for the reply.
The approach i followed is that i post the document directly to the gateway through the REST api.
I do this right after the document is created and skip completely the couchbase lite replication.