Forum: NGINX what exactly does proxy_http_version mean?

Posted by admon.org (Guest)
on 2012-07-03 10:22
(Received via mailing list)
Along with nginx-1.1.4, a new directive named 'proxy_http_version'
introduced
I thought it was something related to the communication between nginx
cache and upstream web server, right?

But per my tests with latest v-1.2.1, Nginx is still using HTTP/1.0 to
access upstream web server.

+++++++++
abc $ curl -I -H 'If-None-Match: "9cx7b1-x2e-44xa4x9axd0x0"'
http://test.stg/crossdomain.xml
HTTP/1.1 200 OK
Server: nginx/1.2.1
...
+++++++++ end

Which intends to return 3.4 if it's using HTTP/1.1, did I misunderstand
this directive?

Thanks for any input..

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,228225,228225#msg-228225
Posted by Francis Daly (Guest)
on 2012-07-03 11:45
(Received via mailing list)
On Tue, Jul 03, 2012 at 04:22:14AM -0400, admon.org wrote:

Hi there,

> Along with nginx-1.1.4, a new directive named 'proxy_http_version'
> introduced
> I thought it was something related to the communication between nginx
> cache and upstream web server, right?

That's what http://nginx.org/r/proxy_http_version says, yes. (Although
I probably wouldn't call it "nginx cache".)

> But per my tests with latest v-1.2.1, Nginx is still using HTTP/1.0 to
> access upstream web server.

How can I repeat your tests? Your results don't match mine.

> Thanks for any input..

cgi script "ex", available on a local http server:

==
#!/bin/sh
echo Content-Type: text/plain
echo
echo SERVER_PROTOCOL=$SERVER_PROTOCOL
==

relevant part of nginx.conf:

==
    server {
        listen       8080;
#  proxy_http_version 1.1;
  location / {
      proxy_pass http://127.0.0.1:10080/ex/;
        }
    }
==

$ curl http://localhost:8080/
SERVER_PROTOCOL=HTTP/1.0

Uncomment the nginx.conf line and reload

$ curl http://localhost:8080/
SERVER_PROTOCOL=HTTP/1.1

$ sbin/nginx -v
nginx version: nginx/1.2.1

  f
--
Francis Daly        francis@daoine.org
Posted by admon.org (Guest)
on 2012-07-03 15:58
(Received via mailing list)
Many thanks Francis!
Here are my configs, I'm using Nginx as a reverse proxy server to cache
static files from its upstream servers.

+++++++++++++++++++++++++++++++++++
    proxy_temp_path   /tmp/proxy_temp_dir;
    proxy_cache_path  /tmp/proxy_cache_dir  levels=1:2
keys_zone=cache_one:200m inactive=1d max_size=30g;

    upstream backend_server {
        server   myserver01 weight=1 max_fails=2 fail_timeout=15s;
        server   myserver02 weight=1 max_fails=2 fail_timeout=15s;
    }

    server {
        listen       80;
        server_name  test.stg
        root   html;
        index  index.html index.htm;

        charset utf-8;

        location / {
            proxy_next_upstream http_502 http_504 error timeout
invalid_header;
            proxy_cache cache_one;
            proxy_cache_valid  200 304 12h;
            proxy_cache_key $host$uri$is_args$args;
            proxy_set_header Host  $host;
            proxy_set_header X-Forwarded-For  $remote_addr;
            proxy_set_header Connection "";

            proxy_pass http://backend_server;
            proxy_http_version   1.1;
            expires      1d;
        }

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


I'm trying to implement a smart way to purge cache e.g. by touching the
file to change its etag. This needs the HTTP/1.1 support. But per my
tests, Nginx does not return expected value.

$ curl -I -H 'If-None-Match: "9cx7b1-x2e-44xa4x9axd0x0"'
http://test.stg/crossdomain.xml

This command gives 200 OK return code, but if I use Varnish instead, it
gives the expected value 304 Not Modified.
So I'm wondering that it may be caused by the protocal between Nginx and
the upstream server.

Can you help have another check. Appriciated!

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,228225,228245#msg-228245
Posted by Maxim Dounin (Guest)
on 2012-07-03 19:13
(Received via mailing list)
Hello!

On Tue, Jul 03, 2012 at 09:58:12AM -0400, admon.org wrote:

> Many thanks Francis!
> Here are my configs, I'm using Nginx as a reverse proxy server to cache
> static files from its upstream servers.

[...]

> the upstream server.
>
> Can you help have another check. Appriciated!

With cache switched on nginx strips all conditional headers in
requests to backends to make sure it'll get full response which
may be cached.  And as nginx itself doesn't support entity tags
yet, the request with If-None-Match doesn't return 304.

Support for entity tags are expected to appear soon, somewhere
near upcoming 1.3.3.

Maxim Dounin
Posted by admon.org (Guest)
on 2012-07-04 05:17
(Received via mailing list)
Maxim, That's Cool, Thanks a lot for your updates!

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,228225,228262#msg-228262
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.