Sign inSign up

egordeev/s3-proxy

By egordeev

Updated 9 months ago

Reverse proxy for AWS S3 with basic authentication.

Image
0

2.9K

egordeev/s3-proxy repository overview

Reverse proxy for AWS S3 w/ basic authentication

Added multiarch support to builds.

NB: https://github.com/pottava/aws-s3-proxy is stale. Switched to a fork https://github.com/patrickdk77/aws-s3-proxy

Description

This is a reverse proxy for AWS S3, which is able to provide basic authentication as well.
You don't need to configure a Bucket for Website Hosting.

http://this-proxy.com/access/ -> s3://bucket/access/index.html

Usage

1. Set environment variables
Environment VariablesDescriptionRequiredDefault
AWS_S3_BUCKETThe S3 bucket to be proxied with this app.*
AWS_S3_KEY_PREFIXYou can configure S3 object key prefix.-
AWS_REGIONThe AWS region where the S3 bucket exists.us-east-1
AWS_ACCESS_KEY_IDAWS access key for API access.EC2 Instance Role
AWS_SECRET_ACCESS_KEYAWS secret key for API access.EC2 Instance Role
AWS_API_ENDPOINTThe endpoint for AWS API for local development.-
INDEX_DOCUMENTName of your index document.index.html
DIRECTORY_LISTINGSList files when a specified URL ends with /.false
DIRECTORY_LISTINGS_FORMATConfigures directory listing to be html (spider parsable) or shtml (pip compatible) or apache for apache style-
DIRECTORY_LISTINGS_CHECK_INDEXCheck for INDEX_DOCUMENT in the folder before listing filesfalse
HTTP_CACHE_CONTROLOverrides S3's HTTP Cache-Control header.S3 Object metadata
HTTP_EXPIRESOverrides S3's HTTP Expires header.S3 Object metadata
BASIC_AUTH_USERUser for basic authentication. Space seperated list-
BASIC_AUTH_PASSPassword for basic authentication. Space seperated list-
SSL_CERT_PATHTLS: cert.pem file path.-
SSL_KEY_PATHTLS: key.pem file path.-
CORS_ALLOW_ORIGINCORS: a URI that may access the resource.-
CORS_ALLOW_METHODSCORS: Comma-delimited list of the allowed HTTP request methods.-
CORS_ALLOW_HEADERSCORS: Comma-delimited list of the supported request headers.-
CORS_MAX_AGECORS: Maximum number of seconds the results of a preflight request can be cached.600
APP_PORTThe port number to be assigned for listening.80
APP_HOSTThe host name used to the listenerListens on all available unicast and anycast IP addresses of the local system.
ACCESS_LOGSend access logs to /dev/stdout.false
FORWARDED_FORHeader name to use to parse proxied ip address from-
STRIP_PATHStrip path prefix.-
CONTENT_ENCODINGCompress response data if the request allows.true
HEALTHCHECK_PATHIf it's specified, the path always returns 200 OK /healthz-
HEALTHCHECKER_PATHUsed by docker healthcheck script, if different from HEALTHCHECK_PATH-
METRICS_PATHprometheus statistics /metrics-
VERSION_PATHversion info of proxy /version-
GET_ALL_PAGES_IN_DIRIf true will make several calls to get all pages of destination directoryfalse
MAX_IDLE_CONNECTIONSAllowed number of idle connections to the S3 storage150
IDLE_CONNECTION_TIMEOUTAllowed timeout to the S3 storage.10
DISABLE_COMPRESSIONIf true will pass encoded content through as-is.true
INSECURE_TLSIf true it will skip cert checksfalse
JWT_SECRET_KEYJSON Web Token secret key to athenticate requests-
JWT_USER_FIELDJSON Web Token field to put in username for logs-
JWT_HEADERJSON Web Token header to use, instead of Authorization, aka Cf-Access-Jwt-Assertion-
SPASignle Page Application - If true server will return index document content on 404 error (like try_files $uri $uri/ /index.html; in nginx)false
WHITELIST_IP_RANGEScommma separated list of IPs and IP ranges.-
CONTENT_TYPEOverride the default Content-Type response header-
CONTENT_DISPOSITIONOverride the default Content-Disposition response header-
USERNAME_HEADERUsername Header name, for cloudflare Cf-Access-Authenticated-User-Email-
SORTSorts file listing (datedesc, dateasc, fileasc, filedesc)fileasc
POST_TIMEOUTTimeout for reads (uploads) in seconds60
GET_TIMEOUTTimeout for writes, responses, in seconds600
2. Run the application

docker run -d -p 8080:80 -e AWS_REGION -e AWS_S3_BUCKET e/s3-proxy

  • with basic auth:

docker run -d -p 8080:80 -e AWS_REGION -e AWS_S3_BUCKET -e BASIC_AUTH_USER -e BASIC_AUTH_PASS egordeev/s3-proxy

  • with TLS:

docker run -d -p 8080:80 -e AWS_REGION -e AWS_S3_BUCKET -e SSL_CERT_PATH -e SSL_KEY_PATH egordeev/s3-proxy

  • with CORS:

docker run -d -p 8080:80 -e CORS_ALLOW_ORIGIN -e CORS_ALLOW_METHODS -e CORS_ALLOW_HEADERS -e CORS_MAX_AGE egordeev/s3-proxy

  • with docker-compose.yml:
proxy:
  image: egordeev/s3-proxy
  ports:
    - 8080:80
  environment:
    - AWS_REGION=ap-northeast-1
    - AWS_ACCESS_KEY_ID
    - AWS_SECRET_ACCESS_KEY
    - AWS_S3_BUCKET
    - BASIC_AUTH_USER=admin
    - BASIC_AUTH_PASS=password
    - ACCESS_LOG=true
  container_name: proxy

Code released under the MIT license.

Tag summary

Content type

Image

Digest

sha256:8961b55eb

Size

7.3 MB

Last updated

9 months ago

docker pull egordeev/s3-proxy