Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a68ed43
Reimplementation of remoteip-rpaf for 2.4.48
AlexAT Jun 2, 2021
0e79fd2
Update mod_remoteip.c
AlexAT Jun 2, 2021
29de5b2
Merge branch 'apache:trunk' into remoteip-rpaf
AlexAT Aug 29, 2021
ade2cc7
Reset HTTPS flag connection note when there is no header content match
AlexAT Mar 23, 2023
e86a0df
Merge branch 'apache:trunk' into remoteip-rpaf
AlexAT Mar 23, 2023
860b89f
Merge branch 'apache:trunk' into remoteip-rpaf
AlexAT Mar 25, 2023
d091bee
Update code based on reviews, part 1
AlexAT Mar 25, 2023
56c3cd4
As two new error message numbers were used, update the next error mes…
AlexAT Mar 25, 2023
4b9e4f2
Update code based on reviews, part 2
AlexAT Mar 26, 2023
21d6bd3
Avoid doing any work on internal subrequests or redirects
AlexAT Mar 26, 2023
0f968f9
Remove FIXME
AlexAT Mar 26, 2023
1ac4c4f
Introduce remote_is_https, local_is_https to mod_lua, alias is_https …
AlexAT Mar 27, 2023
7c4633a
Merge branch 'remoteip-rpaf' of https://github.com/AlexAT/httpd into …
AlexAT Mar 27, 2023
04e11d2
Increment new error numbers as trunk has been changed
AlexAT Mar 27, 2023
325c908
Merge branch 'trunk' into remoteip-rpaf
AlexAT Mar 27, 2023
e6f2a4e
Merge branch 'trunk' into remoteip-rpaf
AlexAT Apr 2, 2023
3dd1e9e
Use empty APLOGNO() for new error messages
AlexAT Apr 2, 2023
3725adb
Merge branch 'trunk' into remoteip-rpaf
AlexAT May 30, 2023
4cfdc3e
Merge branch 'trunk' into remoteip-rpaf
AlexAT Jul 24, 2023
f51112d
Merge branch 'trunk' into remoteip-rpaf
AlexAT Sep 27, 2023
2d8c6c0
Merge branch 'trunk' into remoteip-rpaf
AlexAT May 21, 2024
1287f1b
Merge branch 'trunk' into remoteip-rpaf
AlexAT Jun 3, 2024
b6f00fb
Lost comment close in previous commit
AlexAT Jun 3, 2024
e6ca39c
Merge branch 'trunk' into remoteip-rpaf
AlexAT Aug 1, 2024
5255a92
Merge branch 'trunk' into remoteip-rpaf
AlexAT Aug 2, 2024
cd6aa40
Merge branch 'trunk' into remoteip-rpaf
AlexAT Apr 13, 2025
936029b
Merge branch 'trunk' into remoteip-rpaf
AlexAT Jul 11, 2025
de852c2
Merge branch 'trunk' into remoteip-rpaf
AlexAT Jul 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/manual/mod/mod_lua.html.en.utf8
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,19 @@ end</pre>
<td><code>is_https</code></td>
<td>boolean</td>
<td>no</td>
<td>Whether or not this request is done via HTTPS</td>
<td>Whether or not this request is done via HTTPS (alias to remote_is_https)</td>
</tr>
<tr>
<td><code>remote_is_https</code></td>
<td>boolean</td>
<td>no</td>
<td>Whether or not this request is done via HTTPS locally or on frontend</td>
</tr>
<tr class="odd">
<td><code>local_is_https</code></td>
<td>boolean</td>
<td>no</td>
<td>Whether or not the local connection is done via HTTPS</td>
</tr>
<tr>
<td><code>is_initial_req</code></td>
Expand Down
14 changes: 13 additions & 1 deletion docs/manual/mod/mod_lua.xml
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,19 @@ end
<td><code>is_https</code></td>
<td>boolean</td>
<td>no</td>
<td>Whether or not this request is done via HTTPS</td>
<td>Whether or not this request is done via HTTPS (alias to remote_is_https)</td>
</tr>
<tr>
<td><code>remote_is_https</code></td>
<td>boolean</td>
<td>no</td>
<td>Whether or not this request is done via HTTPS locally or on frontend</td>
</tr>
<tr>
<td><code>local_is_https</code></td>
<td>boolean</td>
<td>no</td>
<td>Whether or not the local connection is done via HTTPS</td>
</tr>
<tr>
<td><code>is_initial_req</code></td>
Expand Down
3 changes: 2 additions & 1 deletion include/ap_mmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,15 @@
* 20211221.29 (2.5.1-dev) Add ap_set_time_process_request() to scoreboard.h
* 20211221.30 (2.5.1-dev) Add ap_stat_check() to httpd.h
* 20211221.31 (2.5.1-dev) Add ap_*_timingsafe() to httpd.h
* 20211221.32 (2.5.1-dev) Add ap_remote_is_ssl() and hooks
*/

#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */

#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20211221
#endif
#define MODULE_MAGIC_NUMBER_MINOR 31 /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 32 /* 0...n */

/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Expand Down
19 changes: 19 additions & 0 deletions include/http_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,25 @@ AP_DECLARE_HOOK(int,force_authn,(request_rec *r))
*/
AP_DECLARE_HOOK(apr_status_t,dirwalk_stat,(apr_finfo_t *finfo, request_rec *r, apr_int32_t wanted))

/**
* This hook allows modules that virtualize SSL state (i.e. mod_remoteip)
* based on the data from remote frontend to register their inquiry function
* for checking if a remote frontend connection is using SSL for the request.
* @param r The current request
* @return OK iff the frontend connection is using SSL, DONE if not,
* DECLINED iff the state is undefined (let later modules decide).
* @ingroup hooks
*/
AP_DECLARE_HOOK(int,remote_is_ssl,(request_rec *r))

/**
* Return != 0 iff the frontend connection for the request is encrypted with SSL.
* If there is no data from the hook (DECLINED), falls back to ap_ssl_conn_is_ssl()
* and so corresponds to the local connection security state (we are the frontend).
* @param r The current request
*/
AP_DECLARE(int) ap_remote_is_ssl(request_rec *r);

AP_DECLARE(int) ap_location_walk(request_rec *r);
AP_DECLARE(int) ap_directory_walk(request_rec *r);
AP_DECLARE(int) ap_file_walk(request_rec *r);
Expand Down
9 changes: 9 additions & 0 deletions modules/lua/lua_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,11 @@ static int req_ssl_is_https_field(request_rec *r)
return ap_lua_ssl_is_https(r->connection);
}

static int req_remote_is_https_field(request_rec *r)
{
return ap_lua_remote_is_https(r);
}

static int req_ap_get_server_port(request_rec *r)
{
return (int) ap_get_server_port(r);
Expand Down Expand Up @@ -2782,7 +2787,11 @@ void ap_lua_load_request_lmodule(lua_State *L, apr_pool_t *p)
apr_hash_set(dispatch, "ssl_var_lookup", APR_HASH_KEY_STRING,
makefun(&req_ssl_var_lookup, APL_REQ_FUNTYPE_LUACFUN, p));
apr_hash_set(dispatch, "is_https", APR_HASH_KEY_STRING,
makefun(&req_remote_is_https_field, APL_REQ_FUNTYPE_BOOLEAN, p));
apr_hash_set(dispatch, "local_is_https", APR_HASH_KEY_STRING,
makefun(&req_ssl_is_https_field, APL_REQ_FUNTYPE_BOOLEAN, p));
apr_hash_set(dispatch, "remote_is_https", APR_HASH_KEY_STRING,
makefun(&req_remote_is_https_field, APL_REQ_FUNTYPE_BOOLEAN, p));
apr_hash_set(dispatch, "assbackwards", APR_HASH_KEY_STRING,
makefun(&req_assbackwards_field, APL_REQ_FUNTYPE_BOOLEAN, p));
apr_hash_set(dispatch, "status", APR_HASH_KEY_STRING,
Expand Down
5 changes: 5 additions & 0 deletions modules/lua/mod_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,11 @@ int ap_lua_ssl_is_https(conn_rec *c)
return ap_ssl_conn_is_ssl(c);
}

int ap_lua_remote_is_https(request_rec *r)
{
return ap_remote_is_ssl(r);
}

/*******************************/

static const char *lua_authz_parse(cmd_parms *cmd, const char *require_line,
Expand Down
1 change: 1 addition & 0 deletions modules/lua/mod_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,6 @@ const char *ap_lua_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c,
request_rec *r, const char *var);

int ap_lua_ssl_is_https(conn_rec *c);
int ap_lua_remote_is_https(request_rec *r);

#endif /* !_MOD_LUA_H_ */
16 changes: 15 additions & 1 deletion modules/mappers/mod_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)

case 5:
if (!strcmp(var, "HTTPS")) {
int flag = ap_ssl_conn_is_ssl(r->connection);
int flag = ap_remote_is_ssl(r);
return apr_pstrdup(r->pool, flag ? "on" : "off");
}
break;
Expand Down Expand Up @@ -2195,6 +2195,13 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)
}
break;

case 'H':
if (!strcmp(var, "HTTPS_LOCAL")) {
int flag = ap_ssl_conn_is_ssl(r->connection);
return apr_pstrdup(r->pool, flag ? "on" : "off");
}
break;

case 'I':
if (!strcmp(var, "API_VERSION")) {
return apr_psprintf(r->pool, "%d:%d",
Expand Down Expand Up @@ -2244,6 +2251,13 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx)

case 12:
switch (var[3]) {
case 'H':
if (!strcmp(var, "HTTPS_REMOTE")) {
int flag = ap_remote_is_ssl(r);
return apr_pstrdup(r->pool, flag ? "on" : "off");
}
break;

case 'I':
if (!strcmp(var, "SCRIPT_GROUP")) {
result = "<unknown>";
Expand Down
Loading