Kirill
Kirill

Reputation: 6036

Why nginx doesn't do simple load balancing. Tomcat instances. Bad request 400

I stuck with a simple task. I have Tomcat cluster of 3 instances available on:

IP = 10.0.0.136 (IP of my machine); Ports = 8180; 8280; 8380;

Then I run nginx with the following nginx.conf:

http {
    upstream tomcat_servers {
        server 10.0.0.136:8180;
        server 10.0.0.136:8280;
        server 10.0.0.136:8380;
    }
...

server {
        listen       8011;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass http://tomcat_servers;       
        }

My Tomcat instances up and running, I can check them in my browser and they show Tomcat's starting page.

However when I come to nginx on localhost:8011 there is Bad Request 400 HTTP status. In logs there are also no errors... I have already restarted nginx, just in case.

This error I get on Mac and Linux Ubuntu.

What I have missed?

The response of nginx: enter image description here

In error.log there are no errors.

access.log: enter image description here

Upvotes: 0

Views: 546

Answers (1)

Kirill
Kirill

Reputation: 6036

I found what was the issue... it is strange however when I use this:

upstream tomcats {...} //in proxy_pass also of course

without sign "_" then all works perfect. I suspected that it might be some my mistake on writing and used simple:

upstream a_b {...}

and also received 400 bad request.

So I don't know why it is so, however this resolve the issue.

I use Ubuntu 18.04 and nginx version: nginx/1.14.0 (Ubuntu)

Upvotes: 1

Related Questions