I have an ubuntu system working as a load balancer and the /etc/nginx/sites-available/default
looks like this:
http {
upstream myapp1 {
server 192.168.0.20:80;
}
server {
listen 80;
location / {
proxy_pass http://myapp1;
}
}
}
On the device with the IP address 192.168.0.20
I have set up a command to listen to all port 80 incoming connections
sudo tcpdump -n -tttt -i eth0 port 80
But when accessing the load balancer through port 80 nothing is picked up by 192.168.0.20
any ideas why this is hapenning?
And the /etc/nginx/sites-available/default
for 192.168.0.20
:
server {
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
root /var/www;
index index.php index.html index.htm;
server_name 192.168.0.20;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
edit for s3v3n
This is what curl -v 192.168.0.20
returns when I run it on the LB:
* Rebuilt URL to: 192.168.0.20/
* Hostname was NOT found in DNS cache
* Trying 192.168.0.20...
* Connected to 192.168.0.20 (192.168.0.20) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.0.20
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.2.1 is not blacklisted
< Server: nginx/1.2.1
< Date: Fri, 13 Mar 2015 14:26:13 GMT
< Content-Type: text/html
< Content-Length: 344
< Last-Modified: Fri, 13 Mar 2015 14:25:58 GMT
< Connection: keep-alive
< Accept-Ranges: bytes
<
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Load balancing set up!</title>
</head>
<body>
Success! You have set it up!!
</body>
</html>
* Connection #0 to host 192.168.0.20 left intact
So if I change my /etc/nginx/sites-available/default
on the LB to:
server {
listen 80;
server_name 192.168.0.20;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://192.168.0.20;
}
}
it works but that is not really giving the option to add more to the cluster?
192.168.0.20
accessible from the host the load balancer is on? Trycurl -v 192.168.0.20
./etc/nginx/sites-enabled
directory?