title: Using variable in nginx conf
body: <p>This works in my Nginx config:</p>
  
  <pre><code>    # This works
      proxy_pass http://GitLab-CE:9080;
  </code></pre>
  
  <p>... but this does not:</p>
  
  <pre><code>    # does not work
      set $upstream_gitlab GitLab-CE;
      proxy_pass http://$upstream_gitlab:9080;
  </code></pre>
  
  <p>This was copied from a different working example which uses a hyphen and a different port.</p>
  
  <pre><code>    # this works
      set $upstream_deluge binhex-delugevpn;
      proxy_pass http://$upstream_deluge:8112;
  </code></pre>
  
  <p>I thought perhaps something to do with the dash, but I have another config which also uses a hyphen in its name (see above) and it works.  I have tried various forms of quotation which doesn't seem to help either.  What could be going on here?  I am at a loss.  What is it about GitLab-CE that doesn't work yet binhex-delugevpn does work?  Is Nginx seeing CE has some hexidecimal math?</p>
  
  <p>Full context:</p>
  
  <pre><code># make sure that your dns has a cname set for gitlab and that your gitlab container is not using a base url
  
  server {
      listen 443 ssl;
      listen [::]:443 ssl;
  
      server_name gitlab.*;
  
      include /config/nginx/ssl.conf;
  
      client_max_body_size 0;
  
      # enable for ldap auth, fill in ldap details in ldap.conf
      #include /config/nginx/ldap.conf;
  
      location / {
          # enable the next two lines for http auth
          auth_basic "Restricted";
          auth_basic_user_file /config/nginx/.htpasswd;
  
          # enable the next two lines for ldap auth
          #auth_request /auth;
          #error_page 401 =200 /login;
  
          include /config/nginx/proxy.conf;
          resolver 127.0.0.11 valid=30s;
          set $upstream_gitlab GitLab-CE;
          proxy_pass http://$upstream_gitlab:9080;
      }
  }
  </code></pre>
  
  <p>I should note that 127.0.0.11 is indeed the correct resolver and the names GitLab-CE and binhex-delugevpn do correctly resolve.</p>
  
  <p>Of course there is no need to use a variable when it is only being referenced a single time but this follows the templates from linuxserver.io's letsencrypt Docker image.</p>
  
  <p><strong>EDIT: more context</strong></p>
  
  <p>Here is /config/nginx/nginx.conf.</p>
  
  <p>It is unmodified by me.</p>
  
  <pre><code>## Version 2018/01/29 - Changelog: https://github.com/linuxserver/docker-letsencrypt/commits/master/root/defaults/nginx.conf
  
  user abc;
  worker_processes 4;
  pid /run/nginx.pid;
  include /etc/nginx/modules/*.conf;
  
  events {
          worker_connections 768;
          # multi_accept on;
  }
  
  http {
  
          ##
          # Basic Settings
          ##
  
          sendfile on;
          tcp_nopush on;
          tcp_nodelay on;
          keepalive_timeout 65;
          types_hash_max_size 2048;
          # server_tokens off;
  
          # server_names_hash_bucket_size 64;
          # server_name_in_redirect off;
  
          client_max_body_size 0;
  
          include /etc/nginx/mime.types;
          default_type application/octet-stream;
  
          ##
          # Logging Settings
          ##
  
          access_log /config/log/nginx/access.log;
          error_log /config/log/nginx/error.log;
  
          ##
          # Gzip Settings
          ##
  
          gzip on;
          gzip_disable "msie6";
  
          # gzip_vary on;
          # gzip_proxied any;
          # gzip_comp_level 6;
          # gzip_buffers 16 8k;
          # gzip_http_version 1.1;
          # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  
          ##
          # nginx-naxsi config
          ##
          # Uncomment it if you installed nginx-naxsi
          ##
  
          #include /etc/nginx/naxsi_core.rules;
  
          ##
          # nginx-passenger config
          ##
          # Uncomment it if you installed nginx-passenger
          ##
  
          #passenger_root /usr;
          #passenger_ruby /usr/bin/ruby;
  
          ##
          # Virtual Host Configs
          ##
          include /etc/nginx/conf.d/*.conf;
          include /config/nginx/site-confs/*;
  
  }
  
  
  #mail {
  #       # See sample authentication script at:
  #       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
  #
  #       # auth_http localhost/auth.php;
  #       # pop3_capabilities "TOP" "USER";
  #       # imap_capabilities "IMAP4rev1" "UIDPLUS";
  #
  #       server {
  #               listen     localhost:110;
  #               protocol   pop3;
  #               proxy      on;
  #       }
  #
  #       server {
  #               listen     localhost:143;
  #               protocol   imap;
  #               proxy      on;
  #       }
  #}
  daemon off;
  </code></pre>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>I have verified that Nginx seems to be doing some "tolower" conversion when using variables.</p>
  
  <p>I renamed my GitLab container to gitlab-ce and it worked fine.
  I renamed my deluge container (and made appropriate edits to the .conf) to binhex-deLugevpn and it stopped working.</p>
  
  <p>Then I renamed it back to binhex-deluge but in the .conf file I put <code>set $upstream_deluge bInHeX-dElUgEvPn;</code></p>
  
  <p>And it worked.  So, nginx (1.14.2) from linuxserver/letsencrypt seems to be doing some lower conversions on variables.</p>
  
  <p>I tried looking <code>find /config -type f -print0 | xargs -0 grep -i lower</code> and found nothing.</p>