Commit 92b3bfa3 authored by Jim Jagielski's avatar Jim Jagielski
Browse files

Merge r1729208, r1735668, r1735668, r1735931, r1735935, r1735942 from trunk:

let proxy handler forward ALPN protocol strings for ssl proxy connections

Remove leftover comment

Remove leftover comment

APLOGNO update for mod_proxy_http2

fix APLOGNO at wrong place, me stupid

h2_proxy_session: fill in missing APLOGNO()s.
Submitted by: icing, jailletc36, jailletc36, icing, icing, ylavic
Reviewed/backported by: jim


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1743577 13f79535-47bb-0310-9956-ffa450edef68
parent a0b2eb80
Loading
Loading
Loading
Loading
+83 −0
Original line number Diff line number Diff line
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision: 1734322 $ -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<modulesynopsis metafile="mod_proxy_http2.xml.meta">

<name>mod_proxy_http2</name>
<description>HTTP/2 support module for
<module>mod_proxy</module></description>
<status>Extension</status>
<sourcefile>mod_proxy_http2.c</sourcefile>
<identifier>proxy_http2_module</identifier>

<summary>
    <p>This module <em>requires</em> the service of <module
    >mod_proxy</module>. It provides the features used for
    proxying HTTP/2 requests. <module>mod_proxy_http2</module>
    supports HTTP/2 only. It does <em>not</em>
    provide any downgrades to HTTP/1.1.</p>

    <p>Thus, in order to get the ability of handling HTTP/2 proxy requests,
    <module>mod_proxy</module> and <module>mod_proxy_http2</module>
    have to be present in the server.</p>

    <p><module>mod_proxy_http2</module> works with incoming requests
    over HTTP/1.1 and HTTP/2 requests. If <module>mod_proxy_http2</module>
    handles the frontend connection, requests against the same HTTP/2
    backend are sent over a single connection, whenever possible.</p>

    <p>This module relies on <a href="http://nghttp2.org/">libnghttp2</a>
    to provide the core http/2 engine.</p>

    <note type="warning"><title>Warning</title>
        <p>This module is experimental. Its behaviors, directives, and 
        defaults are subject to more change from release to 
        release relative to other standard modules. Users are encouraged to 
        consult the "CHANGES" file for potential updates.</p>
    </note>

    <note type="warning"><title>Warning</title>
      <p>Do not enable proxying until you have <a
      href="mod_proxy.html#access">secured your server</a>. Open proxy
      servers are dangerous both to your network and to the Internet at
      large.</p>
    </note>
</summary>
<seealso><module>mod_http2</module></seealso>
<seealso><module>mod_proxy</module></seealso>
<seealso><module>mod_proxy_connect</module></seealso>

<section id="notes"><title>Request notes</title>
    <p><module>mod_proxy_http</module> creates the following request notes for
        logging using the <code>%{VARNAME}n</code> format in
        <directive module="mod_log_config">LogFormat</directive> or
        <directive module="core">ErrorLogFormat</directive>:
    </p>
    <dl>
        <dt>proxy-source-port</dt>
        <dd>The local port used for the connection to the backend server.</dd>
        <dt>proxy-status</dt>
        <dd>The HTTP/2 status received from the backend server.</dd>
    </dl>
</section>

</modulesynopsis>
+287 −0
Original line number Diff line number Diff line
#
# This Makefile requires the environment var NGH2SRC
# pointing to the base directory of nghttp2 source tree.
#

#
# Declare the sub-directories to be built here
#

SUBDIRS = \
	$(EOLIST)

#
# Get the 'head' of the build environment.  This includes default targets and
# paths to tools
#

include $(AP_WORK)/build/NWGNUhead.inc

#
# build this level's files
#
# Make sure all needed macro's are defined
#

#
# These directories will be at the beginning of the include list, followed by
# INCDIRS
#
XINCDIRS	+= \
			$(APR)/include \
			$(APRUTIL)/include \
			$(SRC)/include \
			$(NGH2SRC)/lib/includes \
			$(STDMOD)/proxy \
			$(SERVER)/mpm/NetWare \
			$(NWOS) \
			$(EOLIST)

#
# These flags will come after CFLAGS
#
XCFLAGS		+= \
			$(EOLIST)

#
# These defines will come after DEFINES
#
XDEFINES	+= \
			$(EOLIST)

#
# These flags will be added to the link.opt file
#
XLFLAGS		+= \
			-L$(OBJDIR) \
			$(EOLIST)

#
# These values will be appended to the correct variables based on the value of
# RELEASE
#
ifeq "$(RELEASE)" "debug"
XINCDIRS	+= \
			$(EOLIST)

XCFLAGS		+= \
			$(EOLIST)

XDEFINES	+= \
			$(EOLIST)

XLFLAGS		+= \
			$(EOLIST)
endif

ifeq "$(RELEASE)" "noopt"
XINCDIRS	+= \
			$(EOLIST)

XCFLAGS		+= \
			$(EOLIST)

XDEFINES	+= \
			$(EOLIST)

XLFLAGS		+= \
			$(EOLIST)
endif

ifeq "$(RELEASE)" "release"
XINCDIRS	+= \
			$(EOLIST)

XCFLAGS		+= \
			$(EOLIST)

XDEFINES	+= \
			$(EOLIST)

XLFLAGS		+= \
			$(EOLIST)
endif

#
# These are used by the link target if an NLM is being generated
# This is used by the link 'name' directive to name the nlm.  If left blank
# TARGET_nlm (see below) will be used.
#
NLM_NAME	= proxyht2

#
# This is used by the link '-desc ' directive.
# If left blank, NLM_NAME will be used.
#
NLM_DESCRIPTION	= Apache $(VERSION_STR) HTTP2 Proxy module
#
# This is used by the '-threadname' directive.  If left blank,
# NLM_NAME Thread will be used.
#
NLM_THREAD_NAME	= $(NLM_NAME)

#
# If this is specified, it will override VERSION value in
# $(AP_WORK)/build/NWGNUenvironment.inc
#
NLM_VERSION	=

#
# If this is specified, it will override the default of 64K
#
NLM_STACK_SIZE	= 65536

#
# If this is specified it will be used by the link '-entry' directive
#
NLM_ENTRY_SYM	=

#
# If this is specified it will be used by the link '-exit' directive
#
NLM_EXIT_SYM	=

#
# If this is specified it will be used by the link '-check' directive
#
NLM_CHECK_SYM	=

#
# If this is specified it will be used by the link '-flags' directive
#
NLM_FLAGS	=

#
# If this is specified it will be linked in with the XDCData option in the def
# file instead of the default of $(NWOS)/apache.xdc.  XDCData can be disabled
# by setting APACHE_UNIPROC in the environment
#
XDCDATA		=

#
# Declare all target files (you must add your files here)
#

#
# If there is an NLM target, put it here
#
TARGET_nlm = \
	$(OBJDIR)/$(NLM_NAME).nlm \
	$(EOLIST)

#
# If there is an LIB target, put it here
#
TARGET_lib = \
	$(EOLIST)

#
# These are the OBJ files needed to create the NLM target above.
# Paths must all use the '/' character
#
FILES_nlm_objs = \
	$(OBJDIR)/mod_proxy_http2.o \
	$(OBJDIR)/h2_proxy_session.o \
	$(EOLIST)

#
# These are the LIB files needed to create the NLM target above.
# These will be added as a library command in the link.opt file.
#
FILES_nlm_libs = \
	$(PRELUDE) \
	$(EOLIST)

#
# These are the modules that the above NLM target depends on to load.
# These will be added as a module command in the link.opt file.
#
FILES_nlm_modules = \
	Libc \
	Apache2 \
	mod_proxy \
	mod_http2 \
	$(EOLIST)

#
# If the nlm has a msg file, put it's path here
#
FILE_nlm_msg =

#
# If the nlm has a hlp file put it's path here
#
FILE_nlm_hlp =

#
# If this is specified, it will override $(NWOS)\copyright.txt.
#
FILE_nlm_copyright =

#
# Any additional imports go here
#
FILES_nlm_Ximports = \
	@libc.imp \
	@aprlib.imp \
	@httpd.imp \
	@$(OBJDIR)/mod_http2.imp \
	ap_proxy_acquire_connection \
	ap_proxy_canon_netloc \
	ap_proxy_canonenc \
	ap_proxy_connect_backend \
	ap_proxy_connection_create \
	ap_proxy_cookie_reverse_map \
	ap_proxy_determine_connection \
	ap_proxy_location_reverse_map \
	ap_proxy_port_of_scheme \
	ap_proxy_release_connection \
	ap_proxy_ssl_connection_cleanup \
	ap_sock_disable_nagle \
	proxy_hook_canon_handler \
	proxy_hook_scheme_handler \
	proxy_module \
	proxy_run_detach_backend \
	$(EOLIST)

#
# Any symbols exported to here
#
FILES_nlm_exports = \
	proxy_http2_module \
	$(EOLIST)

#
# These are the OBJ files needed to create the LIB target above.
# Paths must all use the '/' character
#
FILES_lib_objs :=
#
# implement targets and dependancies (leave this section alone)
#

libs :: $(OBJDIR) $(TARGET_lib)

nlms :: libs $(TARGET_nlm)

#
# Updated this target to create necessary directories and copy files to the
# correct place.  (See $(AP_WORK)/build/NWGNUhead.inc for examples)
#
install :: nlms FORCE
	$(call COPY,$(OBJDIR)/*.nlm,        $(INSTALLBASE)/modules/)

clean ::

#
# Any specialized rules here
#

#
# Include the 'tail' makefile that has targets that depend on variables defined
# in this makefile
#

include $(APBUILD)/NWGNUtail.inc

+1356 −0

File added.

Preview size limit exceeded, changes collapsed.

+111 −0
Original line number Diff line number Diff line
/* Copyright 2015 greenbytes GmbH (https://www.greenbytes.de)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef h2_proxy_session_h
#define h2_proxy_session_h

#define H2_ALEN(a)          (sizeof(a)/sizeof((a)[0]))

#include <nghttp2/nghttp2.h>

struct h2_int_queue;
struct h2_ihash_t;

typedef enum {
    H2_PROXYS_ST_INIT,             /* send initial SETTINGS, etc. */
    H2_PROXYS_ST_DONE,             /* finished, connection close */
    H2_PROXYS_ST_IDLE,             /* no streams to process */
    H2_PROXYS_ST_BUSY,             /* read/write without stop */
    H2_PROXYS_ST_WAIT,             /* waiting for tasks reporting back */
    H2_PROXYS_ST_LOCAL_SHUTDOWN,   /* we announced GOAWAY */
    H2_PROXYS_ST_REMOTE_SHUTDOWN,  /* client announced GOAWAY */
} h2_proxys_state;

typedef enum {
    H2_PROXYS_EV_INIT,             /* session was initialized */
    H2_PROXYS_EV_LOCAL_GOAWAY,     /* we send a GOAWAY */
    H2_PROXYS_EV_REMOTE_GOAWAY,    /* remote send us a GOAWAY */
    H2_PROXYS_EV_CONN_ERROR,       /* connection error */
    H2_PROXYS_EV_PROTO_ERROR,      /* protocol error */
    H2_PROXYS_EV_CONN_TIMEOUT,     /* connection timeout */
    H2_PROXYS_EV_NO_IO,            /* nothing has been read or written */
    H2_PROXYS_EV_STREAM_SUBMITTED, /* stream has been submitted */
    H2_PROXYS_EV_STREAM_DONE,      /* stream has been finished */
    H2_PROXYS_EV_STREAM_RESUMED,   /* stream signalled availability of headers/data */
    H2_PROXYS_EV_DATA_READ,        /* connection data has been read */
    H2_PROXYS_EV_NGH2_DONE,        /* nghttp2 wants neither read nor write anything */
    H2_PROXYS_EV_PRE_CLOSE,        /* connection will close after this */
} h2_proxys_event_t;


typedef struct h2_proxy_session h2_proxy_session;
typedef void h2_proxy_request_done(h2_proxy_session *s, request_rec *r,
                                   int complete, int touched);

struct h2_proxy_session {
    const char *id;
    conn_rec *c;
    proxy_conn_rec *p_conn;
    proxy_server_conf *conf;
    apr_pool_t *pool;
    nghttp2_session *ngh2;   /* the nghttp2 session itself */
    
    unsigned int aborted : 1;

    h2_proxy_request_done *done;
    void *user_data;
    
    unsigned char window_bits_stream;
    unsigned char window_bits_connection;

    h2_proxys_state state;
    apr_interval_time_t wait_timeout;

    struct h2_ihash_t *streams;
    struct h2_int_queue *suspended;
    apr_size_t remote_max_concurrent;
    int last_stream_id;     /* last stream id processed by backend, or 0 */
    
    apr_bucket_brigade *input;
    apr_bucket_brigade *output;
};

h2_proxy_session *h2_proxy_session_setup(const char *id, proxy_conn_rec *p_conn,
                                         proxy_server_conf *conf,
                                         unsigned char window_bits_connection,
                                         unsigned char window_bits_stream,
                                         h2_proxy_request_done *done);

apr_status_t h2_proxy_session_submit(h2_proxy_session *s, const char *url,
                                     request_rec *r);
                       
/** 
 * Perform a step in processing the proxy session. Will return aftert
 * one read/write cycle and indicate session status by status code.
 * @param s the session to process
 * @return APR_EAGAIN  when processing needs to be invoked again
 *         APR_SUCCESS when all streams have been processed, session still live
 *         APR_EOF     when the session has been terminated
 */
apr_status_t h2_proxy_session_process(h2_proxy_session *s);

void h2_proxy_session_cleanup(h2_proxy_session *s, h2_proxy_request_done *done);

void h2_proxy_session_update_window(h2_proxy_session *s, 
                                    conn_rec *c, apr_off_t bytes);

#define H2_PROXY_REQ_URL_NOTE   "h2-proxy-req-url"

#endif /* h2_proxy_session_h */
+639 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading