views:

150

answers:

1

My php script calls an url with curl very simply :

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

With this url, i have no problem. But if change to :

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

I have a 400 Bad Request nginx/0.7.62 error

Here's my nginx.conf file :

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;
        }

    }
}

The weirdest thing is that if I call the url below in my browser, it works !

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

@janmoesen i completely forgot to urlencode "a b cd". Thanks for helping.

@Pekka Thanks too ;)

You shouldn't be using this area for replies. StackOverflow is not a forum.
stillstanding