Code Monkey home page Code Monkey logo

s3www's Introduction

s3www

Serve static files from any S3 compatible object storage endpoints.

Simplifies and secure AWS S3 Static Website Hosting by keeping your bucket private, secure, run-anywhere you like and with Automatic TLS based on Let's Encrypt.

Features

  • Automatic credentials rotation when deployed on AWS EC2, ECS or EKS services for your AWS S3 buckets - yay! ๐Ÿ”’๐Ÿ˜
  • Automatic certs renewal for your DOMAIN along with OCSP stapling, full suite of ACME features, HTTP->HTTPS redirection (all thanks to certmagic).

Install

Released binaries are available here, or you can compile yourself from source.

Make sure you have an index.html inside your bucket my-bucket.

Point your web browser to http://127.0.0.1:8080 and ensure your s3www is serving your index.html successfully.

Binary

s3www -endpoint "https://s3.amazonaws.com" -accessKey "accessKey" \
    -secretKey "secretKey" -bucket "my-bucket"

# s3www: Started listening on http://127.0.0.1:8080

Container

podman run --rm -p 8080:8080 y4m4/s3www:latest \
		-endpoint "https://s3.amazonaws.com" \
		-accessKey "accessKey" \
		-secretKey "secretKey" \
		-bucket "my-bucket" \
		-address "0.0.0.0:8080"

# s3www: Started listening on http://0.0.0.0:8080

From source

GO111MODULE=on go get github.com/harshavardhana/s3www

Special files

s3www supports 3 special files:

  • 404.html: A 404 file shown to the user if the request file does not exists.
  • 200.html: A 200 file can be used for PWA / SPA. It will be shown to the users in the same cases as a 404, but returns a 200 http status. Simply copy your index.html file to 200.html to use a SPA with client side routing.
  • index.html / <sub-path>/index.html: An index file will be served if a user requested a path.

Point your web browser to http://127.0.0.1:8080 ensure your s3www is serving your index.html successfully.

Auto TLS

You can use the -lets-encrypt option in combination with -address "example.com" to get automatic lets-encrypt certificates using certmagic.

s3www -endpoint "https://s3.amazonaws.com" -accessKey "accessKey" \
	  -secretKey "secretKey" -bucket "mysite" \
	  -lets-encrypt -address "example.com"

# s3www: Started listening on https://example.com

Build

Binary:

GOOS=linux GOARCH=amd64 go build -ldflags '-w -s' -a -o s3www .

Container:

docker build -t y4m4/s3www:latest .

Permissions

AWS IAM Policy

s3www requires access to view and list all files in the bucket.

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "",
			"Effect": "Allow",
			"Action": "s3:GetObject",
			"Resource": "arn:aws:s3:::<Bucket Name>/*"
		},
		{
			"Sid": "",
			"Effect": "Allow",
			"Action": "s3:ListBucket",
			"Resource": "arn:aws:s3:::<Bucket Name>"
		}
	]
}

License

This project is distributed under the Apache License, Version 2.0, see LICENSE for more information.

s3www's People

Contributors

harshavardhana avatar anbraten avatar oliverisaac avatar aleksandrzhiliaev avatar cuotos avatar lukashass avatar minhdanh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.