title: Angular SPA with Custom --base-href and Nginx Routing
body: <p>We have an angular SPA application that we need to change the base path from </p>
  
  <p>www.site.com 
  to
  www.site.com/app</p>
  
  <p>We added --base-href=/app to our ng build command </p>
  
  <p>RUN ng build --output-path=dist --base-href=/app/ --prod</p>
  
  <p>We have this in our nginx configuration:</p>
  
  <pre><code>location / {
   try_files $uri $uri/ /index.html;
  }
  </code></pre>
  
  <p>We changed it to </p>
  
  <pre><code>location /app/ {
   root /usr/share/nginx/html/app;
   try_files $uri $uri/ /app/index.html;
  }
  </code></pre>
  
  <p>and visiting the site localhost/consumerhub throws a 500 error. This is what I see in the logs:</p>
  
  <p>2019/10/15 19:53:51 [error] 7#7: *1 rewrite or internal redirection cycle while internally redirecting to "/app/index.html", client: 172.17.0.1, server: , request: "GET /app/ HTTP/1.1", host: "localhost:9182"
  172.17.0.1 - - [15/Oct/2019:19:53:51 +0000] "GET /app/ HTTP/1.1" 500 572 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36" "-"</p>
  
  <p>What should it be? Thanks in advance!</p>