Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using Nginx as a caching proxy for ArchLinux mirrors (to speed up internal server builds). It correctly reverse proxies four sites, but returns mysterious 404s on the fifth.

/etc/nginx/conf/nginx.conf:

user http;
worker_processes  2;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/access_log  main;
    error_log   /var/log/error_log  debug;

    sendfile       on;
    tcp_nopush     on;
    tcp_nodelay    off;

    keepalive_timeout  30;

    gzip  on;

    proxy_buffering on;
    proxy_cache_path /srv/http/nginx/proxy levels=1 keys_zone=one:256m inactive=5d max_size=512m;
    proxy_buffer_size 4k;
    proxy_buffers 100 8k;
    proxy_connect_timeout      60;
    proxy_send_timeout         60;
    proxy_read_timeout         60;

    proxy_redirect     off;
    proxy_set_header   Host             $host;
    proxy_set_header   X-Real-IP        $remote_addr;
    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

    proxy_cache             one;
    proxy_cache_key         $request_uri;
    proxy_cache_valid       200 301 302 30m;
    proxy_cache_valid       404 1m;
    proxy_cache_valid       any 15m;
    proxy_cache_use_stale   error timeout invalid_header updating;

    include /etc/nginx/vhosts/*.conf;

}

/etc/nginx/vhosts/default.conf:

server {
    listen       80;
    server_name  mirror.example.com;

    location / {
        root   html;
        index  index.html;
    }

    location /one {
        proxy_pass http://www.gtlib.gatech.edu/pub/linux/distributions/archlinux/;
    }

    location /two {
        proxy_pass http://mirrors.xmission.com/archlinux/;
    }

    location /three {
        proxy_pass http://mirror.rit.edu/archlinux/;
    }

    location /four {
        proxy_pass http://lug.mtu.edu/archlinux/ftpfull/;
    }

    location /five {
        proxy_pass http://repo.archlinux.fr/i686/;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

/one, /two, /three, and /four work flawlessly, but /five always gives a 404. The site is accessible from the server (verified by copy-pasting into lynx). I cannot figure out why. The only thing in the log file is:

Nov 12 09:49:54 mirror NginxMirror: 10.0.1.91 - - [12/Nov/2010:09:49:54 -0500] "GET /five HTTP/1.1" 404 257 "-" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12" "-"

Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

What is this IP - 10.0.1.91 ???

Have you checked your dns? have you checked your not caching something bad in Nginx?

i have just added this to my Nginx configuration

location /five {
    proxy_pass http://repo.archlinux.fr/i686/;
}

And it works :/

P.S take this out

proxy_set_header Host $host;

share|improve this answer
    
Already tried clearing the cache: doesn't work. DNS resolves because it works when I SSH into mirror and lynx http://repo.archlinux.fr/i686/The IP in the log is the computer making the request on the mirror (my desktop). It's just the first example in the logs I found. –  WatersOfOblivion Nov 12 '10 at 15:46
    
Remove the other locations for testing purposes.. Maybe its a bug.. Your config clearly works for the others, its strange it doesnt work for this one –  Arenstar Nov 12 '10 at 15:48
    
Just tried that. Commented out all locations except /five. Didn't work. –  WatersOfOblivion Nov 12 '10 at 16:04
    
hmmm ok ok.. dig repo.archlinux.fr Whats the ip address?? –  Arenstar Nov 12 '10 at 16:07
    
repo.archlinux.fr. 23590 IN A 213.186.62.207 –  WatersOfOblivion Nov 12 '10 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.