Проблемы с реверс прокси nginx с nodejs прилоежнием. Centos8
Опишу, как я настраиваю свой удаленный сервер от digitalocean
Делаю дроплет на Centos 8
Вхожу в систему и меняю пароль
Создаю нового юзера и задаю пароль
adduser shmzl passwd shmzlДаю ему привилегию sudo
gpasswd -a shmzl wheeldnf update and dnf uprage
Отключаю на время SElinux и перезагружаю систему
установка и настройка firewalld
dnf install firewalld -y systemctl start firewalld firewall-cmd --permanent --add-service=(http, http, mysql, openvpn) firewall-cmd --reload (пока что его выключил)Настройка подключению по публичному ключу и дублировании директории ssh пользователю shmzl
Захожу от имени пользователя shmzl
Активирую веб консоль
systemctl enable --now cockpit.socket
Закрываю доступ по паролю
Устанавливаю node js
sudo dnf clean all
sudo dnf makecache fast (пишет, что неправильный аргумент fast, я делал, как в гайде расписано)
sudo dnf install -y gcc-c++ make
sudo dnf install nodejs
Создаю папку, пушу проект
Ставлю pm2
sudo npm install pm2@latest -g
- Ставлю nginx
sudo dnf install nginx
- Настраиваю файл nginx conf (скину текстом его после этого сообщения)
sudo systemctl restart nginx
Создаю группу
WebAdmin, включаю туда пользователя и nginxсоздаю папку
/var/wwwи кидаю туда проект, делаю разрешению права на эту папкуmkdir /var/wwwустанавливаю mysql, создаю базу test
захожу в папку с проектом
npm install
./node..../dbmigrate up
pm2 start app.js
- так же я закинул страницы ошибок в папку с проектом Перехожу по своему домену и nginx выдает страницу ошибки (вот ссылка, если что)
Вот мой nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
server_name test.trinbox.ru;
root /var/www/cd-test;
location / {
proxy_read_timeout 5m;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Вот error log nginx
2020/12/20 17:53:13 [error] 6496#0: *17 connect() failed (111: Connection refused) while connecting to upstream, client: 176.59.97.233, server: test.trinbox.ru, request: "GET / HTTP/1.1", upstream: "http://[::1]:3000/", host: "test.trinbox.ru"
2020/12/20 17:53:13 [error] 6496#0: *17 connect() failed (111: Connection refused) while connecting to upstream, client: 176.59.97.233, server: test.trinbox.ru, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "test.trinbox.ru"
Почему два errora почти одинаковых в одно время? В папке есть еще nginx.conf.default, это может как связано?