nginx-proxy: asterisk VIRTUAL_HOST doesn't work with latest nginx-proxy

I’m using *.domain.com as VIRTUAL_HOST but it fails on recent version of nginx-proxy, it worked before just fine, so I had to roll back to previous version.

Version that works fine is from 5 month ago, idk exact version: screen shot 2017-02-15 at 11 12 01 am

Any ideas what happened in new version?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25 (8 by maintainers)

Most upvoted comments

@sandrodz that was a tricky one, but I got it figured out.

tl;dr

in your docker-compose file, replace

  environment:
    VIRTUAL_HOST: |
      wearede.com,
      www.wearede.com,
      weare.de.com,
      *.weare.de.com
    LETSENCRYPT_HOST: |
      wearede.com,
      www.wearede.com,
      weare.de.com

with

  environment:
    VIRTUAL_HOST: >
      wearede.com,
      www.wearede.com,
      weare.de.com,
      *.weare.de.com
    LETSENCRYPT_HOST: >
      wearede.com,
      www.wearede.com,
      weare.de.com

Analysis

In the yaml syntax, the Block scalar indicator | preserves new line characters. nginx-proxy breaks when there are new line characters in the value of a VIRTUAL_HOST environment variable. (and by the way jrcs/letsencrypt-nginx-proxy-companion has this same restriction for the LETSENCRYPT_HOST environment variable).

The yaml Folded scalar indicator > removes the new lines characters.

@jwilder in the end, #671 or #679 are not involved in the current state of this issue. One way to be more forgiving for users would be to have nginx-proxy trim the $host values from VIRTUAL_HOST as @md5 suggested in #271. In my tests, just adding {{ $host := trim $host }} allows for any kind of white character (new line include) to be part of the VIRTUAL_HOST environment variable without affecting the validity of the nginx configuration file.