Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit 4566fcb

Browse files
lidelStebalien
andcommitted
add config options for proxy/subdomain
Co-authored-by: Steven <[email protected]>
1 parent 91dd90e commit 4566fcb

File tree

1 file changed

+64
-4
lines changed

1 file changed

+64
-4
lines changed

gateway.go

+64-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,71 @@
11
package config
22

3+
type GatewaySpec struct {
4+
// Paths is explicit list of path prefixes that should be handled by
5+
// this gateway. Example: `["/ipfs", "/ipns", "/api"]`
6+
Paths []string
7+
8+
// UseSubdomains indicates whether or not this gateway uses subdomains
9+
// for IPFS resources instead of paths. That is: http://CID.ipfs.GATEWAY/...
10+
//
11+
// If this flag is set, any /ipns/$id and/or /ipfs/$id paths in PathPrefixes
12+
// will be permanently redirected to http://$id.[ipns|ipfs].$gateway/.
13+
//
14+
// We do not support using both paths and subdomains for a single domain
15+
// for security reasons (Origin isolation).
16+
UseSubdomains bool
17+
18+
// NoDNSLink configures this gateway to _not_ resolve DNSLink for the FQDN
19+
// provided in `Host` HTTP header.
20+
NoDNSLink bool
21+
}
22+
323
// Gateway contains options for the HTTP gateway server.
424
type Gateway struct {
5-
HTTPHeaders map[string][]string // HTTP headers to return with the gateway
25+
26+
// HTTPHeaders configures the headers that should be returned by this
27+
// gateway.
28+
HTTPHeaders map[string][]string // HTTP headers to return with the gateway
29+
30+
// RootRedirect is the path to which requests to `/` on this gateway
31+
// should be redirected.
632
RootRedirect string
7-
Writable bool
33+
34+
// Writable enables PUT/POST request handling by this gateway. Usually,
35+
// writing is done through the API, not the gateway.
36+
Writable bool
37+
38+
// PathPrefixes is an array of acceptable url paths that a client can
39+
// specify in X-Ipfs-Path-Prefix header.
40+
//
41+
// The X-Ipfs-Path-Prefix header is used to specify a base path to prepend
42+
// to links in directory listings and for trailing-slash redirects. It is
43+
// intended to be set by a frontend http proxy like nginx.
44+
//
45+
// Example: To mount blog.ipfs.io (a DNSLink site) at ipfs.io/blog
46+
// set PathPrefixes to ["/blog"] and nginx config to translate paths
47+
// and pass Host header (for DNSLink):
48+
// location /blog/ {
49+
// rewrite "^/blog(/.*)$" $1 break;
50+
// proxy_set_header Host blog.ipfs.io;
51+
// proxy_set_header X-Ipfs-Gateway-Prefix /blog;
52+
// proxy_pass http://127.0.0.1:8080;
53+
// }
854
PathPrefixes []string
9-
APICommands []string
10-
NoFetch bool
55+
56+
// FIXME: Not yet implemented
57+
APICommands []string
58+
59+
// NoFetch configures the gateway to _not_ fetch blocks in response to
60+
// requests.
61+
NoFetch bool
62+
63+
// NoDNSLink configures the gateway to _not_ perform DNS TXT record
64+
// lookups in response to requests with values in `Host` HTTP header.
65+
// This flag can be overriden per FQDN in PublicGateways.
66+
NoDNSLink bool
67+
68+
// PublicGateways configures behavior of known public gateways.
69+
// Each key is a fully qualified domain name (FQDN).
70+
PublicGateways map[string]*GatewaySpec
1171
}

0 commit comments

Comments
 (0)