title: Syntax for IF Statement in nginx
body: <p>I have two different server_name in nginx.conf file:<br/>
  First one as:</p>
  
  <pre><code>server_name ~^(?&lt;subdomain&gt;.+)\.nithinveer\.com$;
      location /
              {
                      proxy_pass http://192.168.6.190/Profiles/$subdomain/default.aspx$request_uri/;
                      access_log /var/log/nginx/true.log;
              }
  </code></pre>
  
  <p>Another one as </p>
  
  <pre><code>server_name ~^(?&lt;subdomain&gt;.+)\.nithinveer\.com\.(?&lt;extension&gt;)$;
              location /extension 
              {
                      proxy_pass      http://192.168.6.190;
                      access_log /var/log/nginx/false.log;
              }
  </code></pre>
  
  <p>Now the thing is I want to use both the server_name based on the  in the server_name. If there is no extension with the server_name it should go to first location. If there is an extension, it should go to second location.<br/>
  But while running the nginx, it is not moving into the second server_name<br/>
  Can anyone please find some solution for this...?<br/>
  I thought a solution as(may be wrong).</p>
  
  <pre><code>server_name ~^(?&lt;subdomain&gt;.+)\.nithinveer\.com\.(?&lt;extension&gt;.+)$;
              if($&lt;extension&gt; == NULL)
               {
                     location /
                          {
                      proxy_pass http://192.168.6.190/Profiles/$subdomain/default.aspx$request_uri/;
                      access_log /var/log/nginx/true.log;
                           }
                }
                else
              {       location /
                          {
                            proxy_pass      http://192.168.6.190;
                            access_log /var/log/nginx/false.log;
              }
  </code></pre>
  
  <p>But the syntax with the if statement throws an error.</p>