Traefik as a reverse proxy for S3 Static website

Viewed 1220

Is there a way to set up Traefik as a reverse proxy for S3 Static website hosting?

I tried by using the file provider as follows:

# http routing section
http:
  routers:
    # Define a connection between requests and services
    to-site:
      rule: "PathPrefix(`/site`)"
      middlewares:
        - site-stripprefix
      service: site

  middlewares:
    site-stripprefix:
      stripPrefix:
        prefixes:
          - "/site"

  services:
    # Define how to reach an existing service on our infrastructure
    site:
      loadBalancer:
        servers:
        - url: http://mysite.s3-website-us-east-1.amazonaws.com

It redirects me to https://aws.amazon.com/s3/.

I can't find a setup example of traefik-v2 , only for Nginx.

1 Answers

After setting up the proxy with Nginx I figure this out.

I think Traefik is much more elegant.

For anyone how will need it:

# http routing section
http:
  routers:
    # Define a connection between requests and services
    to-site:
      rule: "PathPrefix(`/site`)"
      middlewares:
        - site-stripprefix
        - site-add-headers
      service: site

  middlewares:
    site-stripprefix:
      stripPrefix:
        prefixes:
          - "/site"
    site-add-headers:
      headers:
        customRequestHeaders:
          Host: "mysite"

  services:
    # Define how to reach an existing service on our infrastructure
    site:
      loadBalancer:
      passHostHeader: false
        servers:
        - url: http://mysite.s3-website-us-east-1.amazonaws.com
Related