Repository navigation
Expand file tree
/
Copy path02-fastcgi-script-overrides.patch
More file actions
130 lines (119 loc) · 3.97 KB
/
Copy path02-fastcgi-script-overrides.patch
File metadata and controls
130 lines (119 loc) · 3.97 KB
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
129
130
Copyright (c) 2020 - 2026 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
@@ -410,6 +410,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
@@ -1057,7 +1060,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
@@ -1068,7 +1073,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.188 2026/10/15 10:59:00 rsadowski 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>
@@ -582,6 +582,8 @@
struct server_header_rules header_rules;
struct server_headers headers;
char errdocroot[HTTPD_ERRDOCROOT_MAX];
+
+ char fcgiscript[PATH_MAX];
TAILQ_ENTRY(server_config) entry;
};
Index: usr.sbin/httpd/parse.y
@@ -155,8 +155,8 @@
%token OCSP ON OPTIONAL
%token PARAM PASS PORT PREFORK PRELOAD PROTOCOLS
%token REMOVE REQUEST REQUESTS RETURN REWRITE ROOT
-%token SACK SERVER SET SOCKET STATIC_CACHE_CONTROL STRIP STYLE SUBDOMAINS
-%token SYSLOG
+%token SACK SCRIPT SERVER SET SOCKET STATIC_CACHE_CONTROL STRIP STYLE
+%token SUBDOMAINS SYSLOG
%token TCP TICKET TIMEOUT TLS TYPE TYPES
%token WITH
%token <v.string> STRING
@@ -1040,6 +1040,16 @@
TAILQ_INSERT_TAIL(&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");
@@ -1768,6 +1778,7 @@
{ "rewrite", REWRITE },
{ "root", ROOT },
{ "sack", SACK },
+ { "script", SCRIPT },
{ "server", SERVER },
{ "set", SET },
{ "socket", SOCKET },
Index: usr.sbin/httpd/server_fcgi.c
@@ -1,6 +1,7 @@
/* $OpenBSD: server_fcgi.c,v 1.103 2026/07/26 14:46:32 rsadowski 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 :