title: Nginx - all domains redirect
body: <p>I looked around to see NGINX configuration for ALL domains and sub-domain but I can only find configurations that are specified.</p>
  
  <p>This is what I want to achieve</p>
  
  <pre><code>server {
      listen 80;
      server_name all;
      return 301 https://www.test.com$request_uri;
  }
  </code></pre>
  
  <p>but then I don't want www.test.com forwarded, only anything else that doesn't match it, even if it is like x.test.com it should be forward too</p>
  
  <p>how I can do it?</p>