У меня есть приложение NodeJS, которое находится в докерезе, и у меня есть контейнер док-станции NGINX, который балансирует нагрузки между процессами NodeJS в контейнерах докеров. Я могу скручивать оба сервера NodeJs успешно, но NGINX не может найти восходящие серверы.Nginx с докционированным NodeJS
Здесь Nginx CONF:
upstream app {
least_conn; # Use Least Connections strategy
server 127.0.0.1:3000; # NodeJS Server 1
server 127.0.0.1:3001; # NodeJS Server 2
}
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/example.com-access.log;
error_log /var/log/nginx/example.com-error.log error;
# Browser and robot always look for these
# Turn off logging for them
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
# Handle static files so they are not proxied to NodeJS
# You may want to also hand these requests to other upstream
# servers, as you can define more than one!
location ~* (images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
root /usr/share/nginx/html;
}
# pass the request to the node.js server
# with some correct headers for proxy-awareness
location/{
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app/;
proxy_redirect off;
# Handle Web Socket connections
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Proxy requests to the mobile api to the mobile api servers (old version of Android App uses m.goodrx.com URLs)
location /mobile-api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://www.goodrx.com/mobile-api;
proxy_redirect off;
# Handle Web Socket connections
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Затем я запустить узел контейнеров связывания портов 3000 и 3001 и контейнер Nginx связывания порт 80. Когда свернуться 127.0.0.1:80 я получаю Bad Request, но керлинг 127.0.0.1:3000 и 127.0.0.1:3001. Любые идеи, что может быть неправильным с прокси-сервером NGINX?