title: Permanent redirect from example.com/ to https://www.example.com/dir/
body: <p>I have some software build with microservice philosophy. On of them - which was hosted on <code>example.com/</code> became useless so I want the user to be redirected to <code>example.com/dir/</code> where another service is hosted. The most popular solution on <code>StackOverflow</code> is to use the following code in the configuration file:</p>
  
  <pre><code>location = / {
      return 301 $scheme://$http_host/dir/;
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>location = / {
      return 301 https://$http_host/dir/;
  }
  </code></pre>
  
  <p>They both fail on my server - the server returns <code>503 - to many computations</code>. The stacktrace shows, that there is no rule-infinite-rule so this code might be returned by <code>load-balancer</code>.</p>
  
  <p>Is there any other well working solution for this issue? <code>StackOverflow</code> and <code>ServerFault</code> have just been carefully searched for the last 3 days by me and any solution worked.</p>