Amazon S3 / Route 53 routing configuration

1

How would I set up a route in Amazon Route 53 ou/e S3 as I do in nodejs with express ? 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 AmazonCloud front + S3 and I am not seeing how to route this way I do with nodejs, I tried to see if I could with Route 53 but could not.

I could just leave running a nodejs application with this routing and heading to CloudFront but I do not really like this idea, the good thing would be straightforward by Amazon

    
asked by anonymous 12.02.2016 / 05:27

1 answer

1

I never needed to do this but I believe it's possible. I recommend looking at the documentation . Something close to that can 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 do not think I can do this dynamically. You would need a route for each group, manually.

    
12.02.2016 / 21:00