nginx“400 Bad Request”

时间:2010-08-17 14:31:28

标签: php curl nginx tornado

我的php脚本非常简单地用curl调用一个url:

$ch = curl_init("http://192.168.0.110:8000/guess/a b c");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r = curl_exec($ch);

有了这个网址,我没有问题。但如果改为:

$ch = curl_init("http://192.168.0.110:8000/guess/a b cd");

我有一个 400 Bad Request nginx / 0.7.62 错误

这是我的nginx.conf文件:

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    use epoll;
}

http {
    # Tornado servers by default
    upstream frontends_a {
        server 127.0.0.1:8001;
        server 127.0.0.1:8002;
        server 127.0.0.1:8003;
        server 127.0.0.1:8004;
    }

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;

    keepalive_timeout 30;
    proxy_read_timeout 30;
    tcp_nopush on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain text/javascript application/json;

    proxy_next_upstream error;

    server {
        listen 8000;

        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_pass http://frontends_a;
        }

    }
}

最奇怪的是,如果我在浏览器中调用下面的url,它就可以了!

http://192.168.0.110:8000/guess/a b cd

0 个答案:

没有答案