mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
HTTP server is now optional
Setting bind_port to 0 the HTTP server will not be started
This commit is contained in:
@@ -59,7 +59,7 @@ Sample SQL scripts to create the required database structure can be found insite
|
|||||||
The `sftpgo.conf` configuration file contains the following sections:
|
The `sftpgo.conf` configuration file contains the following sections:
|
||||||
|
|
||||||
- **"sftpd"**, the configuration for the SFTP server
|
- **"sftpd"**, the configuration for the SFTP server
|
||||||
- `bind_port`, integer the port used for serving SFTP requests. Default: 2022
|
- `bind_port`, integer. The port used for serving SFTP requests. Default: 2022
|
||||||
- `bind_address`, string. Leave blank to listen on all available network interfaces. Default: ""
|
- `bind_address`, string. Leave blank to listen on all available network interfaces. Default: ""
|
||||||
- `idle_timeout`, integer. Time in minutes after which an idle client will be disconnected. Default: 15
|
- `idle_timeout`, integer. Time in minutes after which an idle client will be disconnected. Default: 15
|
||||||
- `max_auth_tries` integer. Maximum number of authentication attempts permitted per connection. If set to a negative number, the number of attempts are unlimited. If set to zero, the number of attempts are limited to 6.
|
- `max_auth_tries` integer. Maximum number of authentication attempts permitted per connection. If set to a negative number, the number of attempts are unlimited. If set to zero, the number of attempts are limited to 6.
|
||||||
@@ -89,7 +89,7 @@ The `sftpgo.conf` configuration file contains the following sections:
|
|||||||
- `manage_users`, integer. Set to 0 to disable users management, 1 to enable
|
- `manage_users`, integer. Set to 0 to disable users management, 1 to enable
|
||||||
- `track_quota`, integer. Set to 0 to disable quota tracking, 1 to update the used quota each time a user upload or delete a file
|
- `track_quota`, integer. Set to 0 to disable quota tracking, 1 to update the used quota each time a user upload or delete a file
|
||||||
- **"httpd"**, the configuration for the HTTP server used to serve REST API
|
- **"httpd"**, the configuration for the HTTP server used to serve REST API
|
||||||
- `bind_port`, integer the port used for serving HTTP requests. Default: 8080
|
- `bind_port`, integer. The port used for serving HTTP requests. Set to 0 to disable HTTP server. Default: 8080
|
||||||
- `bind_address`, string. Leave blank to listen on all available network interfaces. Default: "127.0.0.1"
|
- `bind_address`, string. Leave blank to listen on all available network interfaces. Default: "127.0.0.1"
|
||||||
|
|
||||||
Here is a full example showing the default config:
|
Here is a full example showing the default config:
|
||||||
|
|||||||
9
main.go
9
main.go
@@ -49,10 +49,8 @@ func main() {
|
|||||||
dataProvider := dataprovider.GetProvider()
|
dataProvider := dataprovider.GetProvider()
|
||||||
sftpdConf := config.GetSFTPDConfig()
|
sftpdConf := config.GetSFTPDConfig()
|
||||||
httpdConf := config.GetHTTPDConfig()
|
httpdConf := config.GetHTTPDConfig()
|
||||||
router := api.GetHTTPRouter()
|
|
||||||
|
|
||||||
sftpd.SetDataProvider(dataProvider)
|
sftpd.SetDataProvider(dataProvider)
|
||||||
api.SetDataProvider(dataProvider)
|
|
||||||
|
|
||||||
shutdown := make(chan bool)
|
shutdown := make(chan bool)
|
||||||
|
|
||||||
@@ -64,6 +62,10 @@ func main() {
|
|||||||
shutdown <- true
|
shutdown <- true
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
if httpdConf.BindPort > 0 {
|
||||||
|
router := api.GetHTTPRouter()
|
||||||
|
api.SetDataProvider(dataProvider)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
logger.Debug(logSender, "initializing HTTP server with config %+v", httpdConf)
|
logger.Debug(logSender, "initializing HTTP server with config %+v", httpdConf)
|
||||||
s := &http.Server{
|
s := &http.Server{
|
||||||
@@ -78,6 +80,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
shutdown <- true
|
shutdown <- true
|
||||||
}()
|
}()
|
||||||
|
} else {
|
||||||
|
logger.Debug(logSender, "HTTP server not started, disabled in config file")
|
||||||
|
}
|
||||||
|
|
||||||
<-shutdown
|
<-shutdown
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user