diff --git a/src/infra_version.js b/src/infra_version.js index da6c788f9..66b6a9f4f 100644 --- a/src/infra_version.js +++ b/src/infra_version.js @@ -20,7 +20,7 @@ exports = module.exports = { 'postgresql': { repo: 'cloudron/postgresql', tag: 'cloudron/postgresql:4.3.1@sha256:b0c564d097b765d4a639330843e2e813d2c87fc8ed34b7df7550bf2c6df0012c' }, 'mongodb': { repo: 'cloudron/mongodb', tag: 'cloudron/mongodb:4.2.1@sha256:f7f689beea07b1c6a9503a48f6fb38ef66e5b22f59fc585a92842a6578b33d46' }, 'redis': { repo: 'cloudron/redis', tag: 'cloudron/redis:3.3.0@sha256:89c4e8083631b6d16b5d630d9b27f8ecf301c62f81219d77bd5948a1f4a4375c' }, - 'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.7.0@sha256:510a5ff99543dcc6933a0738344346a84facaf6a886cd1feff6bc736b1f125ff' }, + 'mail': { repo: 'cloudron/mail', tag: 'cloudron/mail:3.7.0@sha256:dec3d830da9d114d5d56cab81f293a523a0defdfdfd962691fcf6ad2039bd5ca' }, 'graphite': { repo: 'cloudron/graphite', tag: 'cloudron/graphite:3.1.0@sha256:30ec3a01964a1e01396acf265183997c3e17fb07eac1a82b979292cc7719ff4b' }, 'sftp': { repo: 'cloudron/sftp', tag: 'cloudron/sftp:3.6.1@sha256:ba4b9a1fe274c0ef0a900e5d0deeb8f3da08e118798d1d90fbf995cc0cf6e3a3' } } diff --git a/src/routes/mailserver.js b/src/routes/mailserver.js index 772b45b80..50bf760b3 100644 --- a/src/routes/mailserver.js +++ b/src/routes/mailserver.js @@ -27,9 +27,8 @@ async function restart(req, res, next) { next(); } -async function proxyToMailContainer(port, req, res, next) { +async function proxyToMailContainer(port, pathname, req, res, next) { const parsedUrl = url.parse(req.url, true /* parseQueryString */); - const pathname = req.path.split('/').pop(); // do not proxy protected values delete parsedUrl.query['access_token']; @@ -40,7 +39,7 @@ async function proxyToMailContainer(port, req, res, next) { if (error) return next(BoxError.toHttpError(error)); parsedUrl.query['access_token'] = addonDetails.token; - req.url = url.format({ pathname: pathname, query: parsedUrl.query }); + req.url = url.format({ pathname, query: parsedUrl.query }); const proxyOptions = url.parse(`http://${addonDetails.ip}:${port}`); const mailserverProxy = middleware.proxy(proxyOptions); @@ -57,11 +56,13 @@ async function proxyToMailContainer(port, req, res, next) { } async function proxy(req, res, next) { - proxyToMailContainer(3000, req, res, next); + const pathname = req.path.split('/').pop(); + + proxyToMailContainer(3000, pathname, req, res, next); } async function queueProxy(req, res, next) { - proxyToMailContainer(6000, req, res, next); + proxyToMailContainer(6000, req.path.replace('/', '/tempfail_queue/'), req, res, next); } async function getLocation(req, res, next) { diff --git a/src/server.js b/src/server.js index b80ef87b8..fbd63fd32 100644 --- a/src/server.js +++ b/src/server.js @@ -299,9 +299,8 @@ function initializeExpressSync() { router.get ('/api/v1/mailserver/mailbox_sharing', token, authorizeAdmin, routes.mailserver.proxy); router.post('/api/v1/mailserver/mailbox_sharing', token, authorizeAdmin, routes.mailserver.proxy, routes.mailserver.restart); router.get ('/api/v1/mailserver/usage', token, authorizeMailManager, routes.mailserver.proxy); - router.get ('/api/v1/mailserver/tempfail_queue', token, authorizeAdmin, routes.mailserver.queueProxy); - router.post('/api/v1/mailserver/tempfail_queue', json, token, authorizeAdmin, routes.mailserver.queueProxy); - router.del ('/api/v1/mailserver/tempfail_queue', token, authorizeAdmin, routes.mailserver.queueProxy); + + router.use ('/api/v1/mailserver/tempfail_queue', token, authorizeAdmin, routes.mailserver.queueProxy); router.get ('/api/v1/mail/:domain', token, authorizeMailManager, routes.mail.getDomain); router.post('/api/v1/mail/:domain/enable', json, token, authorizeAdmin, routes.mail.setMailEnabled);