title: Fourth-Level Subdomain Forwarding
body: <p>I've recently been trying to set up a reverse proxy that would forward certain 4th-level subdomains to particular locations. So, for example, this is what I'm trying to accomplish (configuration in my nginx file):</p>
  
  <pre><code>server {
      listen 80;
      server_name *.server.domain.com;
      rewrite ^ https://$server_name$request_uri;
  }
  </code></pre>
  
  <p>The goal here being that if someone went to, for example, <a href="http://item1.server.domain.com" rel="nofollow noreferrer">http://item1.server.domain.com</a>, they would be re-routed to <a href="https://item1.server.domain.com" rel="nofollow noreferrer">https://item1.server.domain.com</a>. However, with this configuration, the URL gets rewritten to <a href="https://%2A.server.domain.com" rel="nofollow noreferrer">https://%2A.server.domain.com</a>.</p>
  
  <p>Is there a way to fix this so that the full domain (item1) gets added correctly to the rewritten URL? Ideally, I wanted it to eventually be able to rewrite any subdomain on server.domain.com directly to https.</p>
  
  <p>Thanks!</p>