title: AWS Load Balancer, serving static site and an api
body: <p>first of all sorry for my ignorance but there is a concept which is not very clear for me in the AWS ELB word.</p>
  
  <p>I have a frontend site deployed on cloudfront and an API running into an EC2 instance.</p>
  
  <p>What I want to archive is to avoid having 2 domains to serve the same data.</p>
  
  <p>For example I want to access through my site using <a href="https://example.com/post" rel="nofollow noreferrer">https://example.com/post</a> and you will see the site itself (HTML from cloudfront).</p>
  
  <p>But if you are trying to access to <a href="https://example.com/post" rel="nofollow noreferrer">https://example.com/post</a> passing the HTTP/HEADER <code>Accept: application/json</code> you would be able to see the json content from the API server itself (EC2 Instance).</p>
  
  <p>Is that possible using an ELB ? or do I have to make some trick into the EC2 instance like having an nginx seted up as a proxy and serve the cloudfront content if no header is present?</p>
  
  <p>Thanks in advance.</p>