2019-09-29 19:15:31 +00:00
# Running tusd
Starting the tusd upload server is as simple as invoking a single command. For example, following
snippet demonstrates how to start a tusd process which accepts tus uploads at
`http://localhost:1080/files/` (notice the trailing slash) and stores them locally in the `./data` directory:
```
$ tusd -upload-dir=./data
[tusd] 2019/09/29 21:10:50 Using './data' as directory storage.
[tusd] 2019/09/29 21:10:50 Using 0.00MB as maximum size.
[tusd] 2019/09/29 21:10:50 Using 0.0.0.0:1080 as address to listen.
[tusd] 2019/09/29 21:10:50 Using /files/ as the base path.
[tusd] 2019/09/29 21:10:50 Using /metrics as the metrics path.
[tusd] 2019/09/29 21:10:50 Supported tus extensions: creation,creation-with-upload,termination,concatenation,creation-defer-length
[tusd] 2019/09/29 21:10:50 You can now upload files to: http://0.0.0.0:1080/files/
```
Alternatively, if you want to store the uploads on an AWS S3 bucket, you only have to specify
the bucket and provide the corresponding access credentials and region information using
environment variables (if you want to use a S3-compatible store, use can use the `-s3-endpoint`
option):
```
$ export AWS_ACCESS_KEY_ID=xxxxx
$ export AWS_SECRET_ACCESS_KEY=xxxxx
$ export AWS_REGION=eu-west-1
$ tusd -s3-bucket=my-test-bucket.com
[tusd] 2019/09/29 21:11:23 Using 's3://my-test-bucket.com' as S3 bucket for storage.
[tusd] 2019/09/29 21:11:23 Using 0.00MB as maximum size.
[tusd] 2019/09/29 21:11:23 Using 0.0.0.0:1080 as address to listen.
[tusd] 2019/09/29 21:11:23 Using /files/ as the base path.
[tusd] 2019/09/29 21:11:23 Using /metrics as the metrics path.
[tusd] 2019/09/29 21:11:23 Supported tus extensions: creation,creation-with-upload,termination,concatenation,creation-defer-length
[tusd] 2019/09/29 21:11:23 You can now upload files to: http://0.0.0.0:1080/files/
```
2020-08-01 13:07:03 +00:00
If your S3 bucket has been configured for AWS S3 Transfer Acceleration and you want to make use of that advanced service,
you can direct tusd to automatically use the designated AWS acceleration endpoint for your bucket by including the optional
command line flag `s3-transfer-acceleration` as follows:
```
$ export AWS_ACCESS_KEY_ID=xxxxx
$ export AWS_SECRET_ACCESS_KEY=xxxxx
$ export AWS_REGION=eu-west-1
$ tusd -s3-bucket=my-test-bucket.com -s3-transfer-acceleration
[tusd] 2019/09/29 21:11:23 Using 's3://my-test-bucket.com' as S3 bucket for storage with AWS S3 Transfer Acceleration enabled.
[tusd] 2019/09/29 21:11:23 Using 0.00MB as maximum size.
[tusd] 2019/09/29 21:11:23 Using 0.0.0.0:1080 as address to listen.
[tusd] 2019/09/29 21:11:23 Using /files/ as the base path.
[tusd] 2019/09/29 21:11:23 Using /metrics as the metrics path.
[tusd] 2019/09/29 21:11:23 Supported tus extensions: creation,creation-with-upload,termination,concatenation,creation-defer-length
[tusd] 2019/09/29 21:11:23 You can now upload files to: http://0.0.0.0:1080/files/
```
2019-09-29 19:15:31 +00:00
tusd is also able to read the credentials automatically from a shared credentials file (~/.aws/credentials) as described in https://github.com/aws/aws-sdk-go#configuring-credentials.
2020-08-01 13:07:03 +00:00
But be mindful of the need to declare the AWS_REGION value which isn't conventionally associated with credentials.
2019-09-29 19:15:31 +00:00
Furthermore, tusd also has support for storing uploads on Google Cloud Storage. In order to enable this feature, supply the path to your account file containing the necessary credentials:
```
$ export GCS_SERVICE_ACCOUNT_FILE=./account.json
$ tusd -gcs-bucket=my-test-bucket.com
[tusd] Using 'gcs://my-test-bucket.com' as GCS bucket for storage.
[tusd] Using 0.00MB as maximum size.
[tusd] Using 0.0.0.0:1080 as address to listen.
[tusd] Using /files/ as the base path.
[tusd] Using /metrics as the metrics path.
```
2020-09-29 13:19:10 +00:00
TLS support for HTTPS connections can be enabled by supplying a certificate and private key. Note that the certificate file must include the entire chain of certificates up to the CA certificate. The default configuration supports TLSv1.2 and TLSv1.3. It is possible to use only TLSv1.3 with `-tls-mode=tls13` ; alternately, it is possible to disable TLSv1.3 and use only 256-bit AES ciphersuites with `-tls-mode=tls12-strong` . The following example generates a self-signed certificate for `localhost` and then uses it to serve files on the loopback address; that this certificate is not appropriate for production use. Note also that the key file must not be encrypted/require a passphrase.
```
$ openssl req -x509 -new -newkey rsa:4096 -nodes -sha256 -days 3650 -keyout localhost.key -out localhost.pem -subj "/CN=localhost"
Generating a 4096 bit RSA private key
........................++
..........................................++
writing new private key to 'localhost.key'
-----
$ tusd -upload-dir=./data -host=127.0.0.1 -port=8443 -tls-certificate=localhost.pem -tls-key=localhost.key
[tusd] Using './data' as directory storage.
[tusd] Using 0.00MB as maximum size.
[tusd] Using 127.0.0.1:8443 as address to listen.
[tusd] Using /files/ as the base path.
[tusd] Using /metrics as the metrics path.
[tusd] Supported tus extensions: creation,creation-with-upload,termination,concatenation,creation-defer-length
[tusd] You can now upload files to: https://127.0.0.1:8443/files/
```
2019-09-29 19:15:31 +00:00
Besides these simple examples, tusd can be easily configured using a variety of command line
options:
```
$ tusd -help
2022-02-21 11:11:27 +00:00
-azure-blob-access-tier string
Blob access tier when uploading new files (possible values: archive, cool, hot, '')
-azure-container-access-type string
Access type when creating a new container if it does not exist (possible values: blob, container, '')
-azure-endpoint string
Custom Endpoint to use for Azure BlockBlob Storage (requires azure-storage to be pass)
-azure-object-prefix string
Prefix for Azure object names
-azure-storage string
Use Azure BlockBlob Storage with this container name as a storage backend (requires the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY environment variable to be set)
2019-09-29 19:15:31 +00:00
-base-path string
2022-02-21 11:11:27 +00:00
Basepath of the HTTP server (default "/files/")
2019-09-29 19:15:31 +00:00
-behind-proxy
2022-02-21 11:11:27 +00:00
Respect X-Forwarded-* and similar headers which may be set by proxies
-cpuprofile string
write cpu profile to file
2019-09-29 19:15:31 +00:00
-expose-metrics
2022-02-21 11:11:27 +00:00
Expose metrics about tusd usage (default true)
2019-09-29 19:15:31 +00:00
-gcs-bucket string
2022-02-21 11:11:27 +00:00
Use Google Cloud Storage with this bucket as storage backend (requires the GCS_SERVICE_ACCOUNT_FILE environment variable to be set)
2019-09-29 19:15:31 +00:00
-gcs-object-prefix string
2022-02-21 11:11:27 +00:00
Prefix for GCS object names
2019-09-29 19:15:31 +00:00
-hooks-dir string
2022-02-21 11:11:27 +00:00
Directory to search for available hooks scripts
2019-09-29 19:15:31 +00:00
-hooks-enabled-events string
2022-02-21 11:11:27 +00:00
Comma separated list of enabled hook events (e.g. post-create,post-finish). Leave empty to enable default events (default "pre-create,post-create,post-receive,post-terminate,post-finish")
2020-02-24 19:58:15 +00:00
-hooks-grpc string
2022-02-21 11:11:27 +00:00
An gRPC endpoint to which hook events will be sent to
2020-02-24 19:58:15 +00:00
-hooks-grpc-backoff int
2022-02-21 11:11:27 +00:00
Number of seconds to wait before retrying each retry (default 1)
2020-02-24 19:58:15 +00:00
-hooks-grpc-retry int
2022-02-21 11:11:27 +00:00
Number of times to retry on a server error or network timeout (default 3)
2019-09-29 19:15:31 +00:00
-hooks-http string
2022-02-21 11:11:27 +00:00
An HTTP endpoint to which hook events will be sent to
2019-09-29 19:15:31 +00:00
-hooks-http-backoff int
2022-02-21 11:11:27 +00:00
Number of seconds to wait before retrying each retry (default 1)
2020-09-29 13:19:10 +00:00
-hooks-http-forward-headers string
2022-02-21 11:11:27 +00:00
List of HTTP request headers to be forwarded from the client request to the hook endpoint
2019-09-29 19:15:31 +00:00
-hooks-http-retry int
2022-02-21 11:11:27 +00:00
Number of times to retry on a 500 or network timeout (default 3)
2019-09-29 19:15:31 +00:00
-hooks-plugin string
2022-02-21 11:11:27 +00:00
Path to a Go plugin for loading hook functions (only supported on Linux and macOS; highly EXPERIMENTAL and may BREAK in the future)
2019-09-29 19:15:31 +00:00
-hooks-stop-code int
2022-02-21 11:11:27 +00:00
Return code from post-receive hook which causes tusd to stop and delete the current upload. A zero value means that no uploads will be stopped
2019-09-29 19:15:31 +00:00
-host string
2022-02-21 11:11:27 +00:00
Host to bind HTTP server to (default "0.0.0.0")
2019-09-29 19:15:31 +00:00
-max-size int
2022-02-21 11:11:27 +00:00
Maximum size of a single upload in bytes
2019-09-29 19:15:31 +00:00
-metrics-path string
2022-02-21 11:11:27 +00:00
Path under which the metrics endpoint will be accessible (default "/metrics")
2019-09-29 19:15:31 +00:00
-port string
2022-02-21 11:11:27 +00:00
Port to bind HTTP server to (default "1080")
2019-09-29 19:15:31 +00:00
-s3-bucket string
2022-02-21 11:11:27 +00:00
Use AWS S3 with this bucket as storage backend (requires the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION environment variables to be set)
-s3-disable-content-hashes
Disable the calculation of MD5 and SHA256 hashes for the content that gets uploaded to S3 for minimized CPU usage (experimental and may be removed in the future)
-s3-disable-ssl
Disable SSL and only use HTTP for communication with S3 (experimental and may be removed in the future)
2019-09-29 19:15:31 +00:00
-s3-endpoint string
2022-02-21 11:11:27 +00:00
Endpoint to use S3 compatible implementations like minio (requires s3-bucket to be pass)
2019-09-29 19:15:31 +00:00
-s3-object-prefix string
2022-02-21 11:11:27 +00:00
Prefix for S3 object names
2020-09-29 13:19:10 +00:00
-s3-part-size int
2022-02-21 11:11:27 +00:00
Size in bytes of the individual upload requests made to the S3 API. Defaults to 50MiB (experimental and may be removed in the future) (default 52428800)
2020-09-29 13:19:10 +00:00
-s3-transfer-acceleration
2022-02-21 11:11:27 +00:00
Use AWS S3 transfer acceleration endpoint (requires -s3-bucket option and Transfer Acceleration property on S3 bucket to be set)
-show-greeting
Show the greeting message (default true)
2019-09-29 19:15:31 +00:00
-timeout int
2022-02-21 11:11:27 +00:00
Read timeout for connections in milliseconds. A zero value means that reads will not timeout (default 6000)
2020-09-29 13:19:10 +00:00
-tls-certificate string
2022-02-21 11:11:27 +00:00
Path to the file containing the x509 TLS certificate to be used. The file should also contain any intermediate certificates and the CA certificate.
2020-09-29 13:19:10 +00:00
-tls-key string
2022-02-21 11:11:27 +00:00
Path to the file containing the key for the TLS certificate.
2020-09-29 13:19:10 +00:00
-tls-mode string
2022-02-21 11:11:27 +00:00
Specify which TLS mode to use; valid modes are tls13, tls12, and tls12-strong. (default "tls12")
2019-09-29 19:15:31 +00:00
-unix-sock string
2022-02-21 11:11:27 +00:00
If set, will listen to a UNIX socket at this location instead of a TCP socket
2019-09-29 19:15:31 +00:00
-upload-dir string
2022-02-21 11:11:27 +00:00
Directory to store uploads in (default "./data")
2023-02-07 19:10:57 +00:00
-disable-cors
Disables CORS headers. If set to true, tusd will not send any CORS related header. This is useful if you have a proxy sitting in front of tusd that handles CORS (default false)
2019-09-29 19:15:31 +00:00
-verbose
2022-02-21 11:11:27 +00:00
Enable verbose logging output (default true)
2019-09-29 19:15:31 +00:00
-version
2022-02-21 11:11:27 +00:00
Print tusd version information
2019-09-29 19:15:31 +00:00
```