Проблема в том что не могу отправить письмо с сайта который запущен продакшен версии, а в девелоп версии письмо отправляется. Я уже создавал топик раньше по этому поводу. Но щас новые обстоятельства.
Вот логи, но я из них ничего не открыл в плане решения, Это логи nginx
2019/09/02 13:07:43 [error] 20745#20745: *21040 no live upstreams while connecting to upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "GET / HTTP/1.1", upstream: "localhost", host: "alexandra.proto-dev.ru"
2019/09/02 13:11:49 [error] 20745#20745: *21071 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
2019/09/02 13:15:02 [error] 20745#20745: *21085 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
2019/09/02 13:26:14 [error] 20745#20745: *21128 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
2019/09/02 13:53:18 [error] 20745#20745: *21153 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
2019/09/02 13:53:35 [notice] 23002#23002: signal process started
2019/09/02 13:54:26 [error] 23003#23003: *21183 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
2019/09/02 14:00:45 [error] 23003#23003: *21208 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
2019/09/02 14:04:01 [notice] 23361#23361: signal process started
2019/09/02 14:04:32 [error] 23362#23362: *21228 upstream prematurely closed connection while reading response header from upstream, client: 77.222.105.17, server: alexandra.proto-dev.ru, request: "POST /send-email HTTP/1.1", upstream: "127.0.0.1:3000/send-email", host: "alexandra.proto-dev.ru", referrer: "alexandra.proto-dev.ru"
Вот конфиг контейнера
# Настройка сервера
server {
listen 80;
root /var/www/alexandra.proto-dev.ru;
index index.html;
server_name alexandra.proto-dev.ru;
location ~* \.(?:ico|gif|jpe?g|png)$ {
expires 7d;
add_header Vary Accept-Encoding;
access_log off;
}
location / {
client_max_body_size 100m;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
proxy_pass http://localhost:3000;
}
location /nginx/ {
root /var/www/;
autoindex off;
}
location ~ /\. {
deny all;
}
}
Вот конфиг server.js
const fs = require('fs');
const next = require('next');
const express = require('express');
const multer = require('multer');
const nodemailer = require("nodemailer");
const upload = multer({ dest: 'uploads/' });
const port = parseInt(process.env.PORT, 10) || 3000;
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app
.prepare()
.then(() => {
const server = express();
server.get('/', (req, res) => {
const actualPage = '/index';
app.render(req, res, actualPage);
});
server.post('/send-email', upload.single('file'), (req, res, next) => {
const message = {
to: `xxx@inbox.ru`,
subject: `Форма отправлена с сайта alexandra.proto-dev.ru`,
text: `Клиент отправил контактную информацию
Имя: ${req.body.name}
Поятовый ящик: ${req.body.email}
Сообщение: ${req.body.message}`,
attachments: [
{
filename: `${req.file.originalname}`,
content: fs.createReadStream(req.file.path),
},
]
};
const transporter = nodemailer.createTransport(
{
host: 'smtp.mail.ru',
port: 465 ,
secure: true,
auth: {
user: 'xxx@inbox.ru',
pass: 'xxx'
}
},
{
from: `Mailer test xxx@inbox.ru`
}
);
transporter.sendMail(message, (err, info) => {
if (err) {
res.status(500).send('Email Send Error');
}
res.status(200).send('Email Send Successfully');
});
});
server.get('*', (req, res) => {
return handle(req, res)
});
const listenCallback = err => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`)
};
dev ?
server.listen(port, listenCallback) :
server.listen(port, 'localhost', listenCallback);
})
.catch(ex => {
console.error(ex.stack);
process.exit(1);
});