Amazon S3 / Route 53 routing configuration

Asked

Viewed 91 times

1

Could I set a route on Amazon Route 53 ou/e S3 as I do in the nodejs with express ? goes below.

app.get('/', function (req, res) {
    res.sendFile(path.join(__dirname + '/website/index.html'));
});


app.get('/login', function (req, res) {
    res.sendFile(path.join(__dirname + '/login.html'));
});

//Se for qualquer outra rota
app.get('/*', function (req, res) {
    res.redirect('login.html?group='+req.url.substr(1));
});

In short, the directions I want would be

www.meusite.com.br       -> index.html
www.meusite.com.br/login -> login.html
www.meusite.com.br/abc   -> login.html?group=abc
www.meusite.com.br/aaaa  -> login.html?group=aaaa

I would like to use the AmazonCloud front + S3 and I’m not seeing how to route the way I do with the nodejs, I tried to see if I could with the Route 53 but cannot.

Could just leave running an application nodejs with this routing and directing to the CloudFront but I don’t really like this idea, the good would be straight through Amazon

1 answer

1

I never had to do this but I believe it is possible. I recommend looking the documentation. Something around here might work:

<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>login/abc</KeyPrefixEquals>
    </Condition>
    <Redirect>
      <ReplaceKeyWith>login.html?group=abc</ReplaceKeyWith>
    </Redirect>
  </RoutingRule>      
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>login/aaa</KeyPrefixEquals>
    </Condition>
    <Redirect>
      <ReplaceKeyWith>login.html?group=aaa</ReplaceKeyWith>
    </Redirect>
  </RoutingRule>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals>login</KeyPrefixEquals>
    </Condition>
    <Redirect>
      <ReplaceKeyWith>login.html</ReplaceKeyWith>
    </Redirect>
  </RoutingRule>
</RoutingRules>

I just don’t think you can do it dynamically. You would need a route for each group, manually.

  • This, can not make a dynamic route as we do with the Nodejs express, in case, I gave up using Cloudfront, thanks for the reply

Browser other questions tagged

You are not signed in. Login or sign up in order to post.