[#667] Add docs for listen_domains config param

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
support/v0.25
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
```
## 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
- [Configuration](./docs/configuration.md)

View File

@ -265,7 +265,7 @@ func (a *App) Server(ctx context.Context) {
router := mux.NewRouter().SkipClean(true).UseEncodedPath()
// Attach S3 API:
domains := fetchDomains(a.cfg)
domains := a.cfg.GetStringSlice(cfgListenDomains)
a.log.Info("fetch domains, prepare to use API",
zap.Strings("domains", domains))
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
}
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 {
v := viper.New()
@ -216,7 +201,7 @@ func newSettings() *viper.Viper {
flags.StringP(cfgRPCEndpoint, "r", "", "set RPC endpoint")
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:
@ -264,11 +249,7 @@ func newSettings() *viper.Viper {
}
if domains != nil && len(*domains) > 0 {
for i := range *domains {
v.SetDefault(cfgListenDomains+"."+strconv.Itoa(i), (*domains)[i])
}
v.SetDefault(cfgListenDomains+".count", len(*domains))
v.SetDefault(cfgListenDomains, *domains)
}
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_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
S3_GW_CONFIG=/path/to/config/yaml

View File

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

View File

@ -140,6 +140,10 @@ There are some custom types used for brevity:
```yaml
listen_address: 0.0.0.0:8084
listen_domains:
- s3dev.neofs.devenv
- s3dev2.neofs.devenv
rpc_endpoint: http://morph-chain.neofs.devenv:30333
resolve_order:
- nns
@ -163,6 +167,7 @@ allowed_access_key_id_prefixes:
| Parameter | Type | Default value | Description |
|----------------------------------|------------|----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `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). |
| `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. |