How to configure and use HTTP retrievals in Boost
Boost introduced a new binary, booster-http
, with release v1.2.0. This binary can be run alongside the boostd
market process in order to serve retrievals over http.
Currently, there is no payment method or built-in security integrated in the new binary. It can be run with any stable release of boostd
and can also be run on a separate machine from the boostd
process.
Release v1.7.0-rc1 introduced support in booster-http
for running an IPFS gateway, which enables Storage Providers to serve content to their users in multiple formats as described below and demonstrated using curl
.
When performing certain actions, such as replicating deals, it can be convenient to retrieve the entire Piece (with padding) to ensure commp integrity.
To return the CAR file for a given CID, you can pass an Accept
header with the application/vnd.ipld.car;
format. This can be useful for retrieving the raw, unpadded data of a deal.
For Storage Providers that have enabled serving raw files (disabled by default), users can retrieve specific files, such as images by their cid and path where applicable. See Enable serving files for a more in depth example.
For advanced IPFS and IPLD use cases, you can now retrieve individual blocks by passing an Accept
header with the application/vnd.ipld.raw;
format
SPs should try a local setup and test their HTTP retrievals before proceeding to run booster-http
in production.
To build and run booster-http
:
Clone the boost repo and checkout the latest release
Build the new binary
Collect the token information for boost, lotus-miner and lotus daemon API
Start the booster-http
server with the above details
You can run multiple booster-http
processes on the same machine by using a different port for each instance with the --port
flag. You can also run multiple instances of the booster-http
on different machines.
The booster-http server listens on localhost. To expose the server publically, SPs should run a reverse proxy such as NGINX to handle operational concerns like:
SSL
Authentication
Load balancing
While booster-http may get more operational features over time, the intent is that providers who want to scale their HTTP operations will handle most of operational concerns via software in front of booster-http. You can setup a simple NGINX proxy using the example provided in Serving files with booster-http
To enable public discovery of the Boost HTTP server, SPs should set the domain root in boostd's config.toml
. Under the [DealMaking]
section, set HTTPRetrievalMultiaddr
to the public domain root in multi-address format.
Example config.toml
section:
Clients can determine if an SP offers HTTP retrieval by running:
Clients can check the HTTP URL scheme version and supported queries
Clients can download a piece using the domain root configured by the SP:
Configuring booster-http to serve blocks and files
With the release v1.7.0-rc1 of booster-http, Storage Providers can now serve blocks and files directly over the HTTP protocol. booster-http
now implements a IPFS HTTP gateway with a path resolution style. This will allow the clients to download individual IPFS blocks, car files and request uploaded files directly from their browser.
SPs can take advantage of the ecosystem of tools to manage HTTP traffic, like load balancers and reverse proxies.
Before proceeding any further, we request you to read basics of HTTP retrieval configuration. This section is an extension of HTTP retrievals and deals with configuration specific to serving files and raw blocks.
The booster-http
service can be started with specific type of content on IPFS gateway API
This allows SPs to run multiple booster-http
instances, each serving specific type of content like car files only or raw blocks only.
In the curl request below we appended the query parameter format=raw to the URL to get the raw block data for the file.
But, if we try to open the file directly in a web browser, with no extra query parameters, we get an error message:
By default booster-http
does not serve files in a format that can be read by a web browser. This is to protect Storage Providers from serving content that may be flagged as illicit content.
To enable serving files to web browsers, we must pass --serve-files=true
to booster-http
on startup. Once, booster-http
is restarted with --serve-files=true,
we can open the file directly from a web browser:
booster-http
(and booster-bitswap
) automatically filter out known flagged content using the denylist maintained at https://badbits.dwebops.pub/denylist.json
We can also browse all files in the CAR archive.
SPs must secure their booster-http
before exposing it to the public. SPs can feel free to use any tool available to limit who can download files, the number of requests per second, and the download bandwidth each client can use per second.
Users can follow this example to use NGNIX reverse proxy to secure their booster-http
instance. In this section we’ve just scratched the surface of the ways in which nginx can set access limits, rate limits and bandwidth limits. In particular it’s possible to add limits by request token, or using JWT tokens. The examples in this section are adapted from Deploying NGINX as an API Gateway which goes into more detail.
By default nginx puts configuration files into /etc/nginx
The default configuration file is /etc/nginx/sites-available/default
Setup nginx server listen on port 7575
and forward requests to booster-http on port 7777
The IPFS gateway serves files from /ipfs
. So, we will add a server block for location /ipfs/
Let’s limit access to the IPFS gateway using the standard .htaccess
file. We need to set up an .htaccess
file with a username and password. Create a user named alice
Include the .htaccess
file in the /etc/nginx/sites-available/default
Now when we open any URL under the path /ipfs
we will be presented with a Sign in dialog.
To prevent users from making too many requests per second, we should add rate limits.
Create a file with the rate limiting configuration at /etc/nginx/ipfs-gateway.conf.d/ipfs-gateway.conf
Add a request zone limit to the file of 1 request per second, per client IP
Include ipfs-gateway.conf
in /etc/nginx/sites-available/default
and set the response for too many requests to HTTP response code 429
Click the refresh button in your browser on any path under /ipfs more than once per second you will see a 429 error page
It is also recommended to limit the amount of bandwidth that clients can take up when downloading data from booster-http
. This ensures a fair bandwidth distribution to each client and prevents situations where one client ends up choking the booster-http
instance.
Create a new .htaccess user called bob
Add a mapping from .htaccess
username to bandwidth limit in /etc/nginx/ipfs-gateway.conf.d/ipfs-gateway.conf
Add the bandwidth limit to /etc/nginx/sites-available/default
To verify bandwidth limiting, use curl
to download a file with user alice
and then bob
Note the difference in the Average Dload column (the average download speed).