Mercurial > hg > nginx
comparison src/http/ngx_http_spdy.c @ 5605:3a72b1805c52
Added server-side support for PROXY protocol v1 (ticket #355).
Client address specified in the PROXY protocol header is now
saved in the $proxy_protocol_addr variable and can be used in
the realip module.
This is currently not implemented for mail.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 17 Mar 2014 17:41:24 +0400 |
parents | 6808ea2d69e4 |
children | 6c7f9fd5fd7e |
comparison
equal
deleted
inserted
replaced
5604:22d485944c20 | 5605:3a72b1805c52 |
---|---|
93 | 93 |
94 static void ngx_http_spdy_read_handler(ngx_event_t *rev); | 94 static void ngx_http_spdy_read_handler(ngx_event_t *rev); |
95 static void ngx_http_spdy_write_handler(ngx_event_t *wev); | 95 static void ngx_http_spdy_write_handler(ngx_event_t *wev); |
96 static void ngx_http_spdy_handle_connection(ngx_http_spdy_connection_t *sc); | 96 static void ngx_http_spdy_handle_connection(ngx_http_spdy_connection_t *sc); |
97 | 97 |
98 static u_char *ngx_http_spdy_proxy_protocol(ngx_http_spdy_connection_t *sc, | |
99 u_char *pos, u_char *end); | |
98 static u_char *ngx_http_spdy_state_head(ngx_http_spdy_connection_t *sc, | 100 static u_char *ngx_http_spdy_state_head(ngx_http_spdy_connection_t *sc, |
99 u_char *pos, u_char *end); | 101 u_char *pos, u_char *end); |
100 static u_char *ngx_http_spdy_state_syn_stream(ngx_http_spdy_connection_t *sc, | 102 static u_char *ngx_http_spdy_state_syn_stream(ngx_http_spdy_connection_t *sc, |
101 u_char *pos, u_char *end); | 103 u_char *pos, u_char *end); |
102 static u_char *ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, | 104 static u_char *ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, |
419 | 421 |
420 sc->init_window = NGX_SPDY_INIT_STREAM_WINDOW; | 422 sc->init_window = NGX_SPDY_INIT_STREAM_WINDOW; |
421 | 423 |
422 sc->handler = ngx_http_spdy_state_head; | 424 sc->handler = ngx_http_spdy_state_head; |
423 | 425 |
426 if (hc->proxy_protocol) { | |
427 c->log->action = "reading PROXY protocol"; | |
428 sc->handler = ngx_http_spdy_proxy_protocol; | |
429 } | |
430 | |
424 sc->zstream_in.zalloc = ngx_http_spdy_zalloc; | 431 sc->zstream_in.zalloc = ngx_http_spdy_zalloc; |
425 sc->zstream_in.zfree = ngx_http_spdy_zfree; | 432 sc->zstream_in.zfree = ngx_http_spdy_zfree; |
426 sc->zstream_in.opaque = sc; | 433 sc->zstream_in.opaque = sc; |
427 | 434 |
428 rc = inflateInit(&sc->zstream_in); | 435 rc = inflateInit(&sc->zstream_in); |
804 if (c->write->timer_set) { | 811 if (c->write->timer_set) { |
805 ngx_del_timer(c->write); | 812 ngx_del_timer(c->write); |
806 } | 813 } |
807 | 814 |
808 ngx_add_timer(c->read, sscf->keepalive_timeout); | 815 ngx_add_timer(c->read, sscf->keepalive_timeout); |
816 } | |
817 | |
818 | |
819 static u_char * | |
820 ngx_http_spdy_proxy_protocol(ngx_http_spdy_connection_t *sc, u_char *pos, | |
821 u_char *end) | |
822 { | |
823 pos = ngx_proxy_protocol_parse(sc->connection, pos, end); | |
824 | |
825 if (pos == NULL) { | |
826 return ngx_http_spdy_state_protocol_error(sc); | |
827 } | |
828 | |
829 sc->connection->log->action = "processing SPDY"; | |
830 | |
831 return ngx_http_spdy_state_complete(sc, pos, end); | |
809 } | 832 } |
810 | 833 |
811 | 834 |
812 static u_char * | 835 static u_char * |
813 ngx_http_spdy_state_head(ngx_http_spdy_connection_t *sc, u_char *pos, | 836 ngx_http_spdy_state_head(ngx_http_spdy_connection_t *sc, u_char *pos, |