title: Nginx $server_name in if statement
body: <p>It seems like this is not working:</p>
  
  <pre><code>server_name blabla.bla;    
      location ~* (wp-comments-posts|wp-login)\.php$ {
              if ($http_referer !~ ^(http://$servername) ) {
              return 405;
              }
       }
  </code></pre>
  
  <p>While</p>
  
  <pre><code>server_name blabla.bla;    
      location ~* (wp-comments-posts|wp-login)\.php$ {
              if ($http_referer !~ ^(http://blabla.bla) ) {
              return 405;
              }
       }
  </code></pre>
  
  <p>works just fine. Is this expected and if so why? Or am I doing something wrong here?</p>