This commit is contained in:
hongzhidao 2026-07-08 19:08:45 +00:00 committed by GitHub
commit 691671ce8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 8966 additions and 2464 deletions

View file

@ -729,7 +729,8 @@ if [ $HTTP = YES ]; then
ngx_module_name=ngx_http_proxy_module
ngx_module_incs=
ngx_module_deps=src/http/modules/ngx_http_proxy_module.h
ngx_module_deps="src/http/modules/ngx_http_proxy_module.h \
src/http/modules/ngx_http_proxy_v2_module.h"
ngx_module_srcs=src/http/modules/ngx_http_proxy_module.c
ngx_module_libs=
ngx_module_link=$HTTP_PROXY
@ -740,7 +741,8 @@ if [ $HTTP = YES ]; then
if [ $HTTP_FASTCGI = YES ]; then
ngx_module_name=ngx_http_fastcgi_module
ngx_module_incs=
ngx_module_deps=
ngx_module_deps="src/http/modules/ngx_http_proxy_module.h \
src/http/modules/ngx_http_proxy_v2_module.h"
ngx_module_srcs=src/http/modules/ngx_http_fastcgi_module.c
ngx_module_libs=
ngx_module_link=$HTTP_FASTCGI
@ -784,8 +786,11 @@ if [ $HTTP = YES ]; then
if [ $HTTP_PROXY = YES -a $HTTP_V2 = YES ]; then
ngx_module_name=ngx_http_proxy_v2_module
ngx_module_incs=
ngx_module_deps=
ngx_module_srcs=src/http/modules/ngx_http_proxy_v2_module.c
ngx_module_deps="src/http/modules/ngx_http_proxy_v2_module.h \
src/http/modules/ngx_http_proxy_v2_frame.h"
ngx_module_srcs="src/http/modules/ngx_http_proxy_v2_module.c \
src/http/modules/ngx_http_proxy_v2_frame.c \
src/http/modules/ngx_http_proxy_v2_upstream.c"
ngx_module_libs=
ngx_module_link=$HTTP_V2

View file

@ -9,6 +9,9 @@
#include <ngx_core.h>
#include <ngx_http.h>
#include <ngx_http_proxy_module.h>
#if (NGX_HTTP_V2)
#include <ngx_http_proxy_v2_module.h>
#endif
#define NGX_HTTP_PROXY_COOKIE_SECURE 0x0001

View file

@ -116,11 +116,6 @@ ngx_int_t ngx_http_proxy_rewrite_redirect(ngx_http_request_t *r,
ngx_int_t ngx_http_proxy_rewrite_cookie(ngx_http_request_t *r,
ngx_table_elt_t *h);
#if (NGX_HTTP_V2)
ngx_int_t ngx_http_proxy_v2_handler(ngx_http_request_t *r);
#endif
extern ngx_module_t ngx_http_proxy_module;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
/*
* Copyright (C) Maxim Dounin
* Copyright (C) Nginx, Inc.
*/
#ifndef _NGX_HTTP_PROXY_V2_FRAME_H_INCLUDED_
#define _NGX_HTTP_PROXY_V2_FRAME_H_INCLUDED_
#include <ngx_http_proxy_v2_module.h>
ngx_int_t ngx_http_proxy_v2_parse_frame(ngx_http_request_t *r,
ngx_http_proxy_v2_ctx_t *ctx, ngx_buf_t *b);
ngx_int_t ngx_http_proxy_v2_parse_payload(ngx_http_request_t *r,
ngx_http_proxy_v2_ctx_t *ctx, ngx_buf_t *b, ngx_uint_t body);
#endif /* _NGX_HTTP_PROXY_V2_FRAME_H_INCLUDED_ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,137 @@
/*
* Copyright (C) Maxim Dounin
* Copyright (C) Nginx, Inc.
*/
#ifndef _NGX_HTTP_PROXY_V2_H_INCLUDED_
#define _NGX_HTTP_PROXY_V2_H_INCLUDED_
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include <ngx_http_proxy_module.h>
typedef enum {
ngx_http_proxy_v2_st_start = 0,
ngx_http_proxy_v2_st_length_2,
ngx_http_proxy_v2_st_length_3,
ngx_http_proxy_v2_st_type,
ngx_http_proxy_v2_st_flags,
ngx_http_proxy_v2_st_stream_id,
ngx_http_proxy_v2_st_stream_id_2,
ngx_http_proxy_v2_st_stream_id_3,
ngx_http_proxy_v2_st_stream_id_4,
ngx_http_proxy_v2_st_payload,
ngx_http_proxy_v2_st_padding
} ngx_http_proxy_v2_state_e;
typedef enum {
ngx_http_proxy_v2_read_phase_header = 0,
ngx_http_proxy_v2_read_phase_non_buffered,
ngx_http_proxy_v2_read_phase_buffered
} ngx_http_proxy_v2_read_phase_e;
typedef struct {
ngx_buf_t buffer;
ngx_chain_writer_ctx_t writer;
ngx_chain_t *busy;
size_t init_window;
size_t send_window;
size_t recv_window;
ngx_uint_t last_stream_id;
} ngx_http_proxy_v2_conn_t;
typedef struct {
ngx_http_proxy_ctx_t ctx;
ngx_http_proxy_v2_state_e state;
ngx_http_proxy_v2_read_phase_e read_phase;
ngx_uint_t frame_state;
ngx_uint_t fragment_state;
ngx_chain_t *in;
ngx_chain_t *out;
ngx_chain_t *pending;
ngx_chain_t *free;
ngx_http_proxy_v2_conn_t *connection;
ngx_uint_t id;
ngx_uint_t pings;
ngx_uint_t settings;
off_t length;
ssize_t send_window;
size_t recv_window;
size_t rest;
ngx_uint_t stream_id;
u_char type;
u_char flags;
u_char padding;
ngx_uint_t error;
ngx_uint_t window_update;
ngx_uint_t setting_id;
ngx_uint_t setting_value;
ngx_int_t parsed_rc;
u_char ping_data[8];
ngx_uint_t index;
ngx_str_t name;
ngx_str_t value;
u_char *field_end;
size_t field_length;
size_t field_rest;
u_char field_state;
unsigned literal:1;
unsigned field_huffman:1;
unsigned header_sent:1;
unsigned output_closed:1;
unsigned output_blocked:1;
unsigned parsing_headers:1;
unsigned header_initialized:1;
unsigned end_stream:1;
unsigned done:1;
unsigned parsed:1;
unsigned status:1;
unsigned rst:1;
unsigned goaway:1;
} ngx_http_proxy_v2_ctx_t;
ngx_int_t ngx_http_proxy_v2_handler(ngx_http_request_t *r);
ngx_int_t ngx_http_proxy_v2_upstream_create(ngx_http_request_t *r);
void ngx_http_proxy_v2_upstream_init(ngx_http_request_t *r);
ngx_int_t ngx_http_proxy_v2_event_pipe_add_free_buf(ngx_event_pipe_t *p,
ngx_buf_t *b);
ngx_int_t ngx_http_proxy_v2_append_chain(ngx_http_request_t *r,
ngx_http_proxy_v2_ctx_t *ctx, ngx_chain_t *out);
ngx_int_t ngx_http_proxy_v2_flush_output(ngx_http_request_t *r,
ngx_http_proxy_v2_ctx_t *ctx);
ngx_int_t ngx_http_proxy_v2_process_frame_header(ngx_http_request_t *r,
ngx_http_proxy_v2_ctx_t *ctx, ngx_uint_t body);
ngx_int_t ngx_http_proxy_v2_process_frame_payload(ngx_http_request_t *r,
ngx_http_proxy_v2_ctx_t *ctx, ngx_uint_t body);
extern ngx_module_t ngx_http_proxy_v2_module;
#define ngx_http_proxy_v2_frame_tag \
(ngx_buf_tag_t) &ngx_http_proxy_v2_module
#endif /* _NGX_HTTP_PROXY_V2_H_INCLUDED_ */

File diff suppressed because it is too large Load diff

View file

@ -203,7 +203,7 @@ static ngx_int_t ngx_http_upstream_ssl_certificate(ngx_http_request_t *r,
#endif
static ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
{ ngx_string("Status"),
ngx_http_upstream_process_header_line,

View file

@ -458,6 +458,7 @@ ngx_int_t ngx_http_upstream_merge_ssl_passwords(ngx_conf_t *cf,
extern ngx_module_t ngx_http_upstream_module;
extern ngx_http_upstream_header_t ngx_http_upstream_headers_in[];
extern ngx_conf_bitmask_t ngx_http_upstream_cache_method_mask[];
extern ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[];