CouchDB {“error”:”insecure_rewrite_rule”,”reason”:”too many ../.. segments”}

CouchDB {“error”:”insecure_rewrite_rule”,”reason”:”too many ../.. segments”}


Whilst working an AMAZING NPM repository mirror yesterday (which totally works, despite not really offering the performance benefit I’d hoped, because NPM is rubbish) I came across this error whilst doing things


16 http GET https://localhost:5984/registry/_design/app/_rewrite/-/all/since?stale=update_after&startkey=1371737164294
17 http 500 https://localhost:5984/registry/_design/app/_rewrite/-/all/since?stale=update_after&startkey=1371737164294
18 error Error: insecure_rewrite_rule too many ../.. segments: registry/_design/app/_rewrite/-/all/since
18 error at RegClient. (/root/.nvm/v0.8.15/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:259:14)
18 error at Request.init.self.callback (/root/.nvm/v0.8.15/lib/node_modules/npm/node_modules/request/main.js:120:22)
18 error at Request.EventEmitter.emit (events.js:99:17)
18 error at Request. (/root/.nvm/v0.8.15/lib/node_modules/npm/node_modules/request/main.js:648:16)
18 error at Request.EventEmitter.emit (events.js:126:20)
18 error at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (/root/.nvm/v0.8.15/lib/node_modules/npm/node_modules/request/main.js:610:14)
18 error at IncomingMessage.EventEmitter.emit (events.js:126:20)
18 error at IncomingMessage._emitEnd (http.js:366:10)
18 error at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
18 error at Socket.socketOnData [as ondata] (http.js:1367:20)
19 error If you need help, you may report this log at:
19 error
19 error or email it to:
19 error

Visiting that URL in a web browser gave me

{"error":"insecure_rewrite_rule","reason":"too many ../.. segments"}

This is because secure rewrites are enabled! Looking at my couchdb config this occured in the default.ini

secure_rewrites = true

so in the [http] segment in the local.ini file i set it to false, in your face security model!

secure_rewrites = false

Then i restarted couchdb, and the world was put to rights and the error went away.

Leave a Reply

Your email address will not be published. Required fields are marked *