mirror of https://github.com/go-gitea/gitea.git
Replace "unix" by "http+unix" for PROTOCOL (#17771)
This commit is contained in:
parent
9d6208965c
commit
f49d160447
|
@ -180,7 +180,7 @@ func setPort(port string) error {
|
||||||
setting.HTTPPort = port
|
setting.HTTPPort = port
|
||||||
|
|
||||||
switch setting.Protocol {
|
switch setting.Protocol {
|
||||||
case setting.UnixSocket:
|
case setting.HTTPUnix:
|
||||||
case setting.FCGI:
|
case setting.FCGI:
|
||||||
case setting.FCGIUnix:
|
case setting.FCGIUnix:
|
||||||
default:
|
default:
|
||||||
|
@ -202,7 +202,7 @@ func setPort(port string) error {
|
||||||
|
|
||||||
func listen(m http.Handler, handleRedirector bool) error {
|
func listen(m http.Handler, handleRedirector bool) error {
|
||||||
listenAddr := setting.HTTPAddr
|
listenAddr := setting.HTTPAddr
|
||||||
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
|
if setting.Protocol != setting.HTTPUnix && setting.Protocol != setting.FCGIUnix {
|
||||||
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)
|
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)
|
||||||
}
|
}
|
||||||
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
|
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
|
||||||
|
@ -240,7 +240,7 @@ func listen(m http.Handler, handleRedirector bool) error {
|
||||||
NoHTTPRedirector()
|
NoHTTPRedirector()
|
||||||
}
|
}
|
||||||
err = runFCGI("tcp", listenAddr, "FCGI Web", m)
|
err = runFCGI("tcp", listenAddr, "FCGI Web", m)
|
||||||
case setting.UnixSocket:
|
case setting.HTTPUnix:
|
||||||
if handleRedirector {
|
if handleRedirector {
|
||||||
NoHTTPRedirector()
|
NoHTTPRedirector()
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||||
|
|
||||||
## Server (`server`)
|
## Server (`server`)
|
||||||
|
|
||||||
- `PROTOCOL`: **http**: \[http, https, fcgi, unix, fcgi+unix\]
|
- `PROTOCOL`: **http**: \[http, https, fcgi, http+unix, fcgi+unix\]
|
||||||
- `DOMAIN`: **localhost**: Domain name of this server.
|
- `DOMAIN`: **localhost**: Domain name of this server.
|
||||||
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
|
- `ROOT_URL`: **%(PROTOCOL)s://%(DOMAIN)s:%(HTTP\_PORT)s/**:
|
||||||
Overwrite the automatically generated public URL.
|
Overwrite the automatically generated public URL.
|
||||||
|
@ -248,7 +248,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||||
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
|
- `HTTP_ADDR`: **0.0.0.0**: HTTP listen address.
|
||||||
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
|
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
|
||||||
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
|
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
|
||||||
- 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.
|
- 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.
|
||||||
- `HTTP_PORT`: **3000**: HTTP listen port.
|
- `HTTP_PORT`: **3000**: HTTP listen port.
|
||||||
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
|
- If `PROTOCOL` is set to `fcgi`, Gitea will listen for FastCGI requests on TCP socket
|
||||||
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
|
defined by `HTTP_ADDR` and `HTTP_PORT` configuration settings.
|
||||||
|
@ -257,7 +257,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
|
||||||
(DMZ) URL for Gitea workers (such as SSH update) accessing web service. In
|
(DMZ) URL for Gitea workers (such as SSH update) accessing web service. In
|
||||||
most cases you do not need to change the default value. Alter it only if
|
most cases you do not need to change the default value. Alter it only if
|
||||||
your SSH server node is not the same as HTTP node. Do not set this variable
|
your SSH server node is not the same as HTTP node. Do not set this variable
|
||||||
if `PROTOCOL` is set to `unix`.
|
if `PROTOCOL` is set to `http+unix`.
|
||||||
- `PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the connection. (Set to 0 to
|
- `PER_WRITE_TIMEOUT`: **30s**: Timeout for any write to the connection. (Set to 0 to
|
||||||
disable all timeouts.)
|
disable all timeouts.)
|
||||||
- `PER_WRITE_PER_KB_TIMEOUT`: **10s**: Timeout per Kb written to connections.
|
- `PER_WRITE_PER_KB_TIMEOUT`: **10s**: Timeout per Kb written to connections.
|
||||||
|
|
|
@ -46,7 +46,7 @@ func newInternalRequest(ctx context.Context, url, method string) *httplib.Reques
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
ServerName: setting.Domain,
|
ServerName: setting.Domain,
|
||||||
})
|
})
|
||||||
if setting.Protocol == setting.UnixSocket {
|
if setting.Protocol == setting.HTTPUnix {
|
||||||
req.SetTransport(&http.Transport{
|
req.SetTransport(&http.Transport{
|
||||||
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
|
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
|
||||||
var d net.Dialer
|
var d net.Dialer
|
||||||
|
|
|
@ -39,11 +39,11 @@ type Scheme string
|
||||||
|
|
||||||
// enumerates all the scheme types
|
// enumerates all the scheme types
|
||||||
const (
|
const (
|
||||||
HTTP Scheme = "http"
|
HTTP Scheme = "http"
|
||||||
HTTPS Scheme = "https"
|
HTTPS Scheme = "https"
|
||||||
FCGI Scheme = "fcgi"
|
FCGI Scheme = "fcgi"
|
||||||
FCGIUnix Scheme = "fcgi+unix"
|
FCGIUnix Scheme = "fcgi+unix"
|
||||||
UnixSocket Scheme = "unix"
|
HTTPUnix Scheme = "http+unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LandingPage describes the default page
|
// LandingPage describes the default page
|
||||||
|
@ -607,7 +607,8 @@ func loadFromConf(allowEmpty bool) {
|
||||||
HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
|
HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
|
||||||
|
|
||||||
Protocol = HTTP
|
Protocol = HTTP
|
||||||
switch sec.Key("PROTOCOL").String() {
|
protocolCfg := sec.Key("PROTOCOL").String()
|
||||||
|
switch protocolCfg {
|
||||||
case "https":
|
case "https":
|
||||||
Protocol = HTTPS
|
Protocol = HTTPS
|
||||||
CertFile = sec.Key("CERT_FILE").String()
|
CertFile = sec.Key("CERT_FILE").String()
|
||||||
|
@ -620,24 +621,22 @@ func loadFromConf(allowEmpty bool) {
|
||||||
}
|
}
|
||||||
case "fcgi":
|
case "fcgi":
|
||||||
Protocol = FCGI
|
Protocol = FCGI
|
||||||
case "fcgi+unix":
|
case "fcgi+unix", "unix", "http+unix":
|
||||||
Protocol = FCGIUnix
|
switch protocolCfg {
|
||||||
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
|
case "fcgi+unix":
|
||||||
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
|
Protocol = FCGIUnix
|
||||||
if err != nil || UnixSocketPermissionParsed > 0777 {
|
case "unix":
|
||||||
log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
|
log.Warn("unix PROTOCOL value is deprecated, please use http+unix")
|
||||||
}
|
fallthrough
|
||||||
UnixSocketPermission = uint32(UnixSocketPermissionParsed)
|
case "http+unix":
|
||||||
if !filepath.IsAbs(HTTPAddr) {
|
Protocol = HTTPUnix
|
||||||
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
|
}
|
||||||
}
|
|
||||||
case "unix":
|
|
||||||
Protocol = UnixSocket
|
|
||||||
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
|
UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
|
||||||
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
|
UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
|
||||||
if err != nil || UnixSocketPermissionParsed > 0777 {
|
if err != nil || UnixSocketPermissionParsed > 0777 {
|
||||||
log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
|
log.Fatal("Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
|
||||||
}
|
}
|
||||||
|
|
||||||
UnixSocketPermission = uint32(UnixSocketPermissionParsed)
|
UnixSocketPermission = uint32(UnixSocketPermissionParsed)
|
||||||
if !filepath.IsAbs(HTTPAddr) {
|
if !filepath.IsAbs(HTTPAddr) {
|
||||||
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
|
HTTPAddr = filepath.Join(AppWorkPath, HTTPAddr)
|
||||||
|
@ -692,7 +691,7 @@ func loadFromConf(allowEmpty bool) {
|
||||||
|
|
||||||
var defaultLocalURL string
|
var defaultLocalURL string
|
||||||
switch Protocol {
|
switch Protocol {
|
||||||
case UnixSocket:
|
case HTTPUnix:
|
||||||
defaultLocalURL = "http://unix/"
|
defaultLocalURL = "http://unix/"
|
||||||
case FCGI:
|
case FCGI:
|
||||||
defaultLocalURL = AppURL
|
defaultLocalURL = AppURL
|
||||||
|
|
Loading…
Reference in New Issue