nginx serving wrong website under proxy_cache

Payam Chychi pchychi at
Wed Apr 29 06:27:00 MSD 2009

hey guys,

So I had 3 sites configured to use caching on my nginx box (tried with
.50, 52 and 53 build) however of the three websites kept redirecting
me to the first site that I was doing caching for.

Example Sites:

HTTP config very similar to this only each utilize a different
"listen" ip address and each site has a different Backend 'Origin" ip:

 upstream LB_HTTP_0.0.0.1 {
 server x.x.x.x:80;

    server {

        server_name  website_0.0.0.1;

         access_log      /var/log/nginx/any.website_0.0.0.1.access_log main;
         error_log       /var/log/nginx/any.website_0.0.0.1.error_log info;

        error_page  404  /404.html;
        location = /404.html {
            root   html;
        error_page  404 500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

         location / {
         proxy_intercept_errors on;
         proxy_pass              http://LB_HTTP_0.0.0.1;
         proxy_cache             one;
         proxy_cache_key         backend$request_uri;
         proxy_cache_valid       200  1h;
         proxy_cache_valid       404 5m;
         proxy_cache_use_stale   error timeout invalid_header;

When browsing to, everything was fine
going to or or any other ip for that matter in the
same class C "/24" it would redirect you to the config which
would then proxy-pass the data back to the origin belonging to the config

Anyone seen this issue at all?
Once i commented all proxy_cache and restarted nginx, problem went away.

Note that i even tried deleting /etc/nginx-cache/* and recreating
it... did not help

Payam Tarverdyan Chychi
Network Security Specialist / Network Engineer

More information about the nginx mailing list