1

I read this article but I can't make my case work https://stackoverflow.com/questions/3334023/configure-multiple-sites-with-varnish

This is my problem

I have 2 domain : mysite1.com and mysite2.com

This is my config in default.vcl

backend default {
    .host = "127.0.0.1";
    .port = "8080";
}


backend mysite2 {
    .host = "127.0.0.1";
    .port = "8080";
}

sub vcl_recv {
    if (req.http.host == "mysite1.com" || req.http.host == "www.mysite1.com") {
        set req.backend = default;
    } elsif (req.http.host == "mysite2.com" || req.http.host == "www.mysite2.com") {
        set req.backend = mysite2;
    }
}

and now is ngix config in /etc/ngix/site-avaiable/mysite2

server {

server_name mysite2.com;
#server_name localhost;
listen 127.0.0.1:8080;
root /home/mysite2/sites/mysite2
// some bla bla here
}

My problem is whenever I try to connect to mysite2.com, everything with be move to mysite1.com.

If I turn off varnish, everthing is ok, but when I turn it on, I got this error, I think my config is not correct, but I don't know why, any one have experience with it?

1 Answer 1

1

You've got overlapping listeners in your nginx and varnish configurations.

If Varnish is listening on 8080, you need Nginx to listen on port 80, and send requests through to 8080. The way to do this is with the proxy_pass statement.

1
  • Yes, you're right, the problem is nginx config, i re-config nginx for mysite2.com lik this server { server_name mysite2.com; #server_name localhost; #listen 8080; root /home/mysite2/sites/mysite2 // some bla bla here } just remove listen
    – Tung Can
    Jul 4, 2016 at 3:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .