I
I
Ilya2014-11-06 23:42:41
Nginx
Ilya, 2014-11-06 23:42:41

Nginx: listen to 2 ip at once?

Is it possible to listen to several ip at once. No redirects.
Let's say we have a config like this:

upstream example.com {
    server unix:/tmp/example.com.sock fail_timeout=0;
}

server {
    listen 127.0.0.1:80;
    client_max_body_size 4G;
    server_name example.com;
    access_log  /home/user/logs/example.com.access.log;
    keepalive_timeout 5;

    root /home/user/projects/example.com/;
    
    location / {
        proxy_pass http://example.com;
    }
    
    location = /robots.txt {
        expires 30d;
        add_header Cache-Control public;
        try_files /robots.txt @shared;
    }
}

If you add 1 more ip after listen 127.0.0.1:80, will it work on two ip at once?
I just want to change the ip of the server. I took the VDS, and he is blacklisted. For a month, only those who did not install antivirus programs had access to the site. There are no viruses on the site itself, I checked it with all online tools, just the ip itself is blacklisted. I wrote to antivirusniks, but they do not itch.
Now I bought a new ip from a hoster and I want to change it to it. But the DNS is not immediately updated, you need to make sure that the site is available on both ips.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WebSpider, 2014-11-07
@FireGM

Yes, this is how it will work

server {
  listen 127.0.0.1:80;
  listen 192.168.0.1:80;
  ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question