Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

Nginx returning 404 when accessing it through varnish server over public IP

I'm trying to serve static contents through varnish(client<-varnish<-nginx) but I'm having an issue accessing it through public IP. Varnish is working fine when accessing it locally (where varnish is running) but throws status 404 when accessing it through public IP.

My flow looks like this:

Client--> Caching_Server[NGINX(used for SSL support only) -> Varnish] --> Origin_Server[Nginx]

My varnish server config is as simple as:

probe healthcheck {
    .url = "http://10.10.10.3/healthcheck";
    .timeout = 2s;
    .interval = 30s;
    .window = 5;
    .threshold = 3;
}
backend default {
    .host = "10.10.10.3";
    .port = "80";
    .probe = healthcheck;
}



sub vcl_recv {

    if (req.url ~ ".ts$") {
     unset req.http.Cookie;
    }

    set req.backend_hint = default;
}

I also checked the Nginx logs and I see that it's throwing 404 which explains why varnish is responding with 404. But my question is why is it working when I test it locally using localhost.

question from:https://stackoverflow.com/questions/65869825/nginx-returning-404-when-accessing-it-through-varnish-server-over-public-ip

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The output from varnishlog -g request -q "ReqUrl eq '/'" will probably give you the answer to your question.

Run the command while sending a request internally, and a request from the internet. Compare the output, and see where there's a difference.

If you need help, add the logs of both requests to your question and I'll help you examine the situation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...