diff --git a/cmd/fsd/main.go b/cmd/fsd/main.go index 1326466..704a9c3 100644 --- a/cmd/fsd/main.go +++ b/cmd/fsd/main.go @@ -37,7 +37,9 @@ var ( Bucket: "ipfs", }, IPFS: config.IPFS{ - GatewayAddress: ":8080", + Gateway: config.HTTPGateway{ + ListenAddress: ":8080", + }, }, API: config.API{ Address: ":8081", @@ -164,7 +166,7 @@ func main() { } defer apiListener.Close() - gatewayListener, err := net.Listen("tcp", cfg.IPFS.GatewayAddress) + gatewayListener, err := net.Listen("tcp", cfg.IPFS.Gateway.ListenAddress) if err != nil { log.Fatal("failed to listen", zap.Error(err)) } diff --git a/config/config.go b/config/config.go index 7a624fe..2deba97 100644 --- a/config/config.go +++ b/config/config.go @@ -8,13 +8,19 @@ type ( Bucket string `yaml:"bucket"` } - // IPFS contains the listen address of the IPFS gateway + // HTTPGateway contains the configuration for the IPFS HTTP gateway + HTTPGateway struct { + ListenAddress string `yaml:"ListenAddress"` + RedirectPathStyle bool `yaml:"redirectPathStyle"` + } + + // IPFS contains the configuration for the IPFS node IPFS struct { - PrivateKey string `yaml:"privateKey"` - GatewayAddress string `yaml:"gatewayAddress"` - ListenAddresses []string `yaml:"listenAddresses"` - AnnounceAddresses []string `yaml:"announceAddresses"` - FetchRemote bool `yaml:"fetchRemote"` + PrivateKey string `yaml:"privateKey"` + ListenAddresses []string `yaml:"listenAddresses"` + AnnounceAddresses []string `yaml:"announceAddresses"` + FetchRemote bool `yaml:"fetchRemote"` + Gateway HTTPGateway `yaml:"gateway"` } // API contains the listen address of the API server diff --git a/http/ipfs.go b/http/ipfs.go index 8fc8712..fb0bd1e 100644 --- a/http/ipfs.go +++ b/http/ipfs.go @@ -88,7 +88,7 @@ func (is *ipfsGatewayServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { redirect = true } - if redirect { + if redirect && is.config.IPFS.Gateway.RedirectPathStyle { redirectPathCID(w, r, c, path, is.log.Named("redirect")) return }