phiilu / mailman

Mailman is a GUI to help you manage your email accounts stored in a MySQL/MariaDB database.
MIT License
70 stars 10 forks source link

Using unix socket and nginx as reverse proxy to access web server #42

Open casswarry0 opened 4 years ago

casswarry0 commented 4 years ago

To make mailman open a unix socket for the web server I had to change the file: /opt/mailman/build/main.js

where it was: const server = app.listen(port, process.env.MAILMAN_HOST || "0.0.0.0", () => console.log("Mailman is running on http://%s:%d%s in %s mode", server.address().address, server.address().port, base, "production"));

I made: var server; if (process.env.MAILMAN_SOCKET) { var fs = require('fs'); server = app.listen(process.env.MAILMAN_SOCKET, () => console.log("Mailman is running on socket %s in %s mode", process.env.MAILMAN_SOCKET, "production"), () => fs.chmodSync(process.env.MAILMAN_SOCKET, '666')); } else { server = app.listen(port, process.env.MAILMAN_HOST || "0.0.0.0", () => console.log("Mailman is running on http://%s:%d%s in %s mode", server.address().address, server.address().port, base, "production")); }

In /opt/mailman/.env define: MAILMAN_SOCKET=/path/to/socket

In nginx the configuration include: proxy_pass http://unix:/path/to/socket:$uri$is_args$args;