Nginx Complains about the following part of my configuration:
nginx: [emerg] unknown directive "if($domain" in /etc/nginx/nginx.conf:38 nginx: configuration file /etc/nginx/nginx.conf test failed
Here is the bit he is talking about:
server_name ~^(?:(?<subdomain>\w*)\.)?(?<domain>\w+)\.(?<tld>(?:\w+\.?)+)$; if($domain = "co") { set $domain "${subdomain}"; set $subdomain "www"; set $tld "co.${tld}"; } if ($subdomain = "") { set $subdomain "www"; } root /var/www/sites/$domain.$tld/$subdomain; location / { index index.php index.html index.htm; }
Here is the complete server section of my configuration file:
server { listen 80; server_name ~^(?:(?<subdomain>\w*)\.)?(?<domain>\w+)\.(?<tld>(?:\w+\.?)+)$; if($domain = "co") { set $domain "${subdomain}"; set $subdomain "www"; set $tld "co.${tld}"; } if ($subdomain = "") { set $subdomain "www"; } root /var/www/sites/$domain.$tld/$subdomain; location / { index index.php index.html index.htm; } }
What is the problem?
source share