-
Notifications
You must be signed in to change notification settings - Fork 3
/
02-fastcgi-script-overrides.patch
128 lines (118 loc) · 3.93 KB
/
02-fastcgi-script-overrides.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Copyright (c) 2020 - 2024 Matthias Pressfreund
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Index: usr.sbin/httpd/httpd.conf.5
@@ -360,6 +360,9 @@
If the
.Ar port
is not specified, it defaults to port 9000.
+.It Ic script Ar path
+Override the determined script with the one specified by the given
+.Ar path .
.It Ic strip Ar number
Strip
.Ar number
@@ -877,7 +880,9 @@
.Pp
The
.Ic location not found
-option may be used to enable
+option (here in combination with the
+.Ic fastcgi script
+override directive) may be used to enable
.Lk https://wordpress.org/support/article/using-permalinks/ WordPress Pretty Permalinks
just like on an Apache web server with
.Pa mod_rewrite
@@ -888,7 +893,10 @@
directory index "index.php"
location not found "/*" {
- request rewrite "/index.php"
+ fastcgi {
+ socket "/run/php-fpm.sock"
+ script "/index.php"
+ }
}
location "/*.php" {
fastcgi socket "/run/php-fpm.sock"
Index: usr.sbin/httpd/httpd.h
@@ -1,7 +1,7 @@
/* $OpenBSD: httpd.h,v 1.165 2024/10/08 05:28:11 jsg Exp $ */
/*
- * Copyright (c) 2020 Matthias Pressfreund
+ * Copyright (c) 2020, 2021 Matthias Pressfreund
* Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org>
* Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -543,6 +543,8 @@
struct server_fcgiparams fcgiparams;
int fcgistrip;
char errdocroot[HTTPD_ERRDOCROOT_MAX];
+
+ char fcgiscript[PATH_MAX];
TAILQ_ENTRY(server_config) entry;
};
Index: usr.sbin/httpd/parse.y
@@ -141,7 +141,7 @@
%token TIMEOUT TLS TYPE TYPES HSTS MAXAGE SUBDOMAINS DEFAULT PRELOAD REQUEST
%token ERROR INCLUDE AUTHENTICATE WITH BLOCK DROP RETURN PASS REWRITE
%token CA CLIENT CRL OPTIONAL PARAM FORWARDED FOUND NOT
-%token ERRDOCS GZIPSTATIC CACHE
+%token ERRDOCS GZIPSTATIC CACHE SCRIPT
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.port> port
@@ -800,6 +800,16 @@
param->name, param->value);
TAILQ_INSERT_HEAD(&srv_conf->fcgiparams, param, entry);
}
+ | SCRIPT STRING {
+ if (strlcpy(srv_conf->fcgiscript, $2,
+ sizeof(srv_conf->fcgiscript)) >=
+ sizeof(srv_conf->fcgiscript)) {
+ yyerror("fastcgi script override too long");
+ free($2);
+ YYERROR;
+ }
+ free($2);
+ }
| STRIP NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid fastcgi strip number");
@@ -1501,6 +1511,7 @@
{ "rewrite", REWRITE },
{ "root", ROOT },
{ "sack", SACK },
+ { "script", SCRIPT },
{ "server", SERVER },
{ "socket", SOCKET },
{ "strip", STRIP },
Index: usr.sbin/httpd/server_fcgi.c
@@ -1,6 +1,7 @@
/* $OpenBSD: server_fcgi.c,v 1.97 2023/11/08 19:19:10 millert Exp $ */
/*
+ * Copyright (c) 2020, 2021 Matthias Pressfreund
* Copyright (c) 2014 Florian Obser <florian@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -163,9 +164,12 @@
h->type = FCGI_PARAMS;
h->content_len = param.total_len = 0;
- alias = desc->http_path_alias != NULL
- ? desc->http_path_alias
- : desc->http_path;
+ if (*srv_conf->fcgiscript == '\0') {
+ alias = desc->http_path_alias != NULL
+ ? desc->http_path_alias
+ : desc->http_path;
+ } else
+ alias = srv_conf->fcgiscript;
query_alias = desc->http_query_alias != NULL
? desc->http_query_alias