Skip to content

Commit f49d160

Browse files
authored
Replace "unix" by "http+unix" for PROTOCOL (#17771)
1 parent 9d62089 commit f49d160

File tree

4 files changed

+25
-26
lines changed

4 files changed

+25
-26
lines changed

cmd/web.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func setPort(port string) error {
180180
setting.HTTPPort = port
181181

182182
switch setting.Protocol {
183-
case setting.UnixSocket:
183+
case setting.HTTPUnix:
184184
case setting.FCGI:
185185
case setting.FCGIUnix:
186186
default:
@@ -202,7 +202,7 @@ func setPort(port string) error {
202202

203203
func listen(m http.Handler, handleRedirector bool) error {
204204
listenAddr := setting.HTTPAddr
205-
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
205+
if setting.Protocol != setting.HTTPUnix && setting.Protocol != setting.FCGIUnix {
206206
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)
207207
}
208208
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
@@ -240,7 +240,7 @@ func listen(m http.Handler, handleRedirector bool) error {
240240
NoHTTPRedirector()
241241
}
242242
err = runFCGI("tcp", listenAddr, "FCGI Web", m)
243-
case setting.UnixSocket:
243+
case setting.HTTPUnix:
244244
if handleRedirector {
245245
NoHTTPRedirector()
246246
}

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
233233

234234
## Server (`server`)
235235

236-
- `PROTOCOL`: **http**: \[http, https, fcgi, unix, fcgi+unix\]
236+
- `PROTOCOL`: **http**: \[http, https, fcgi, http+unix, fcgi+unix\]
237237
- `DOMAIN`: **localhost**: Domain name of this server.
238238
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
239239
Overwrite the automatically generated public URL.
@@ -248,7 +248,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
248248
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
249249
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
250250
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
251-
- If `PROTOCOL` is set to `unix` or `fcgi+unix`, this should be the name of the Unix socket file to use. Relative paths will be made absolute against the AppWorkPath.
251+
- If `PROTOCOL` is set to `http+unix` or `fcgi+unix`, this should be the name of the Unix socket file to use. Relative paths will be made absolute against the AppWorkPath.
252252
- `HTTP_PORT`: **3000**: HTTP listen port.
253253
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
254254
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
@@ -257,7 +257,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
257257
(DMZ) URL for Gitea workers (such as SSH update) accessing web service. In
258258
most cases you do not need to change the default value. Alter it only if
259259
your SSH server node is not the same as HTTP node. Do not set this variable
260-
if `PROTOCOL` is set to `unix`.
260+
if `PROTOCOL` is set to `http+unix`.
261261
- `PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the connection. (Set to 0 to
262262
disable all timeouts.)
263263
- `PER_WRITE_PER_KB_TIMEOUT`: **10s**: Timeout per Kb written to connections.

modules/private/internal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func newInternalRequest(ctx context.Context, url, method string) *httplib.Reques
4646
InsecureSkipVerify: true,
4747
ServerName: setting.Domain,
4848
})
49-
if setting.Protocol == setting.UnixSocket {
49+
if setting.Protocol == setting.HTTPUnix {
5050
req.SetTransport(&http.Transport{
5151
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
5252
var d net.Dialer

modules/setting/setting.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ type Scheme string
3939

4040
// enumerates all the scheme types
4141
const (
42-
HTTP Scheme = "http"
43-
HTTPS Scheme = "https"
44-
FCGI Scheme = "fcgi"
45-
FCGIUnix Scheme = "fcgi+unix"
46-
UnixSocket Scheme = "unix"
42+
HTTP Scheme = "http"
43+
HTTPS Scheme = "https"
44+
FCGI Scheme = "fcgi"
45+
FCGIUnix Scheme = "fcgi+unix"
46+
HTTPUnix Scheme = "http+unix"
4747
)
4848

4949
// LandingPage describes the default page
@@ -607,7 +607,8 @@ func loadFromConf(allowEmpty bool) {
607607
HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
608608

609609
Protocol = HTTP
610-
switch sec.Key("PROTOCOL").String() {
610+
protocolCfg := sec.Key("PROTOCOL").String()
611+
switch protocolCfg {
611612
case "https":
612613
Protocol = HTTPS
613614
CertFile = sec.Key("CERT_FILE").String()
@@ -620,24 +621,22 @@ func loadFromConf(allowEmpty bool) {
620621
}
621622
case "fcgi":
622623
Protocol = FCGI
623-
case "fcgi+unix":
624-
Protocol = FCGIUnix
625-
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
626-
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
627-
if err != nil || UnixSocketPermissionParsed > 0777 {
628-
log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
624+
case "fcgi+unix", "unix", "http+unix":
625+
switch protocolCfg {
626+
case "fcgi+unix":
627+
Protocol = FCGIUnix
628+
case "unix":
629+
log.Warn("unix PROTOCOL value is deprecated, please use http+unix")
630+
fallthrough
631+
case "http+unix":
632+
Protocol = HTTPUnix
629633
}
630-
UnixSocketPermission = uint32(UnixSocketPermissionParsed)
631-
if !filepath.IsAbs(HTTPAddr) {
632-
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
633-
}
634-
case "unix":
635-
Protocol = UnixSocket
636634
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
637635
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
638636
if err != nil || UnixSocketPermissionParsed > 0777 {
639637
log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
640638
}
639+
641640
UnixSocketPermission = uint32(UnixSocketPermissionParsed)
642641
if !filepath.IsAbs(HTTPAddr) {
643642
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
@@ -692,7 +691,7 @@ func loadFromConf(allowEmpty bool) {
692691

693692
var defaultLocalURL string
694693
switch Protocol {
695-
case UnixSocket:
694+
case HTTPUnix:
696695
defaultLocalURL = "http://unix/"
697696
case FCGI:
698697
defaultLocalURL = AppURL

0 commit comments

Comments
 (0)