[#667] Add docs for listen_domains config param

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-08-30 13:52:37 +03:00 committed by Alex Vanin
parent b1d3dbe2b5
commit 7668d5fb2f
6 changed files with 42 additions and 22 deletions

View file

@ -54,6 +54,33 @@ $ S3_GW_PEERS_0_ADDRESS=grpcs://192.168.130.72:8080 \
neofs-s3-gw neofs-s3-gw
``` ```
## Domains
By default, s3-gw enable only `path-style access`.
To be able to use both: `virtual-hosted-style` and `path-style` access you must configure `listen_domains`:
```shell
$ neofs-s3-gw -p 192.168.130.72:8080 --wallet wallet.json --listen_domains your.first.domain --listen_domains your.second.domain
```
So now you can use (e.g. `HeadBucket`. Make sure DNS is properly configured):
```shell
$ curl --head http://bucket-name.your.first.domain:8080
HTTP/1.1 200 OK
...
```
or
```shell
$ curl --head http://your.second.domain:8080/bucket-name
HTTP/1.1 200 OK
...
```
Also, you can configure domains using `.env` variables or `yaml` file.
## Documentation ## Documentation
- [Configuration](./docs/configuration.md) - [Configuration](./docs/configuration.md)

View file

@ -265,7 +265,7 @@ func (a *App) Server(ctx context.Context) {
router := mux.NewRouter().SkipClean(true).UseEncodedPath() router := mux.NewRouter().SkipClean(true).UseEncodedPath()
// Attach S3 API: // Attach S3 API:
domains := fetchDomains(a.cfg) domains := a.cfg.GetStringSlice(cfgListenDomains)
a.log.Info("fetch domains, prepare to use API", a.log.Info("fetch domains, prepare to use API",
zap.Strings("domains", domains)) zap.Strings("domains", domains))
api.Attach(router, domains, a.maxClients, a.api, a.ctr, a.log) api.Attach(router, domains, a.maxClients, a.api, a.ctr, a.log)

View file

@ -161,21 +161,6 @@ func fetchPeers(l *zap.Logger, v *viper.Viper) []pool.NodeParam {
return nodes return nodes
} }
func fetchDomains(v *viper.Viper) []string {
cnt := v.GetInt(cfgListenDomains + ".count")
res := make([]string, 0, cnt)
for i := 0; ; i++ {
domain := v.GetString(cfgListenDomains + "." + strconv.Itoa(i))
if domain == "" {
break
}
res = append(res, domain)
}
return res
}
func newSettings() *viper.Viper { func newSettings() *viper.Viper {
v := viper.New() v := viper.New()
@ -216,7 +201,7 @@ func newSettings() *viper.Viper {
flags.StringP(cfgRPCEndpoint, "r", "", "set RPC endpoint") flags.StringP(cfgRPCEndpoint, "r", "", "set RPC endpoint")
resolveMethods := flags.StringSlice(cfgResolveOrder, []string{resolver.DNSResolver}, "set bucket name resolve order") resolveMethods := flags.StringSlice(cfgResolveOrder, []string{resolver.DNSResolver}, "set bucket name resolve order")
domains := flags.StringArrayP(cfgListenDomains, "d", nil, "set domains to be listened") domains := flags.StringSliceP(cfgListenDomains, "d", nil, "set domains to be listened")
// set defaults: // set defaults:
@ -264,11 +249,7 @@ func newSettings() *viper.Viper {
} }
if domains != nil && len(*domains) > 0 { if domains != nil && len(*domains) > 0 {
for i := range *domains { v.SetDefault(cfgListenDomains, *domains)
v.SetDefault(cfgListenDomains+"."+strconv.Itoa(i), (*domains)[i])
}
v.SetDefault(cfgListenDomains+".count", len(*domains))
} }
switch { switch {

View file

@ -28,6 +28,9 @@ S3_GW_LISTEN_ADDRESS=0.0.0.0:8080
S3_GW_TLS_CERT_FILE=/path/to/tls/cert S3_GW_TLS_CERT_FILE=/path/to/tls/cert
S3_GW_TLS_KEY_FILE=/path/to/tls/key S3_GW_TLS_KEY_FILE=/path/to/tls/key
# Domains to be able to use virtual-hosted-style access to bucket.
S3_GW_LISTEN_DOMAINS=s3dev.neofs.devenv
# Config file # Config file
S3_GW_CONFIG=/path/to/config/yaml S3_GW_CONFIG=/path/to/config/yaml

View file

@ -31,6 +31,10 @@ tls:
cert_file: /path/to/cert cert_file: /path/to/cert
key_file: /path/to/key key_file: /path/to/key
# Domains to be able to use virtual-hosted-style access to bucket.
listen_domains:
- s3dev.neofs.devenv
logger: logger:
level: debug level: debug

View file

@ -140,6 +140,10 @@ There are some custom types used for brevity:
```yaml ```yaml
listen_address: 0.0.0.0:8084 listen_address: 0.0.0.0:8084
listen_domains:
- s3dev.neofs.devenv
- s3dev2.neofs.devenv
rpc_endpoint: http://morph-chain.neofs.devenv:30333 rpc_endpoint: http://morph-chain.neofs.devenv:30333
resolve_order: resolve_order:
- nns - nns
@ -163,6 +167,7 @@ allowed_access_key_id_prefixes:
| Parameter | Type | Default value | Description | | Parameter | Type | Default value | Description |
|----------------------------------|------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |----------------------------------|------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `listen_address` | `string` | `0.0.0.0:8080` | The address that the gateway is listening on. | | `listen_address` | `string` | `0.0.0.0:8080` | The address that the gateway is listening on. |
| `listen_domains` | `[]string` | | Domains to be able to use virtual-hosted-style access to bucket. |
| `rpc_endpoint` | `string` | | The address of the RPC host to which the gateway connects to resolve bucket names (required to use the `nns` resolver). | | `rpc_endpoint` | `string` | | The address of the RPC host to which the gateway connects to resolve bucket names (required to use the `nns` resolver). |
| `resolve_order` | `[]string` | `[dns]` | Order of bucket name resolvers to use. Available resolvers: `dns`, `nns`. | | | `resolve_order` | `[]string` | `[dns]` | Order of bucket name resolvers to use. Available resolvers: `dns`, `nns`. | |
| `connect_timeout` | `duration` | `10s` | Timeout to connect to a node. | | `connect_timeout` | `duration` | `10s` | Timeout to connect to a node. |