הגדר Let’s Encrypt עם דומיינים מרובים / הפניות

Hi @pfaffman, the edit to the original post has an erroneous + in the to: line, breaking the regex. It should be removed.

Separately, the following paragraph needs to be edited as it no longer makes sense:

There are two patterns that need to be replaced, one ending in --keylength , and another ending in --fullchainpath (in the actual file, your original domain is before each of these switches). Enter your (sub)domain (and any additional subdomains preceded by -d ) and then add the following to your app.yml hooks section (towards the end of the file):

I suggest:

Use domain1 and domain2 in this post to generate the code that you will need. domain1 is your original domain and domain2 is the additional domain that you want to add. Add the resulting after_ssl: block to the hooks: section of your app.yml and do a launcher rebuild app.

לייק 1

Oops. I removed the + and tweaked the text. I’ll look again later when I’m at a computer

Hey @textkit, this is a wiki, so you can make further edits if you like.

Since the last update to 3.5.0.beta8-dev

/etc/runit/1.d/letsencrypt

is missing in the docker container. So it will not build. Workaround: https://www.forcewww.com/

So this stopped working:

## Add Let's Encrypt cert for non-www and www domain name
  after_ssl:
    - replace:
        filename: "/etc/runit/1.d/letsencrypt"
        from: /--keylength/
        to: "-d example.de -d www.example.de --keylength"

Before removing such tools/binaries from the Docker container, it would be nice to receive a notification…

4 לייקים

האם זה שינוי באופן שבו Discourse מטפל ב-LetsEncrypt או שינוי ב-LetsEncrypt עצמו?

יש לי שרת שכרגע מושפע מהבעיה הזו. לעת עתה, הפתרון העוקף שלי הוא להעיר את החלק הזה של app.yml, אבל אני מרגיש שאנחנו צריכים דרך להוסיף את האישורים הנוספים האלה להגדרה בעתיד.

2 לייקים

Discourse העביר את זה לקובץ אחר. כרגע עובדים על זה. אנסה לבדוק בימים הקרובים מה נדרש כדי לאפשר תמיכה במספר תתי-דומיינים.

2 לייקים

ערכתי את ה-OP עם תבנית חדשה, אך עדיין לא בדקתי אותה.

לייק 1

Nope, this doesn’t work:

FAILED

Errno::ENOENT: No such file or directory @ rb_sysopen - /usr/local/bin/letsencrypt
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/replace_command.rb:11:in `read’
replace failed with the params {“filename”=>“/usr/local/bin/letsencrypt”, “from”=>“/-d spokes.nz/”, “to”=>“-d spokes.nz -d www.spokes.nz”}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

2 לייקים

כנראה מוקדם מדי.

אולי נסה לשים את ההחלפה בבית התחתון היכן שהיה פעם ה-ssh, אם זה הגיוני (אני בטלפון, אנסה להסתכל מחר)

לייק 1

Hi @nathank

Guessing here but I wonder if the error you are getting might relate to a missing space before the final slash and the final quote in the respective lines of the suggested stanza in your app.yml file?

I am inferring from the error message that your respective lines are (verbatim)

from: /-d spokes.nz/
to: “-d spokes.nz -d www.spokes.nz”

I say this, because in my case the lines are

from: /-d nzarchitecture.net.nz /
to: "-d nzarchitecture.net.nz -d www.nzarchitecture.net.nz "

And with spaces just before the end of each line as shown, I can now rebuild Discourse without throwing that error. (if you look closely you will see @pfaffman‘s updated stanza posted at start of this thread did show those extra spaces).

I have no files at all in the usr/local/bin/ directory (as noted in your error message) either, which made me suspect that lack of that letsencrypt file is not what triggers the error.

That said, for me while Discourse works ok on its url nzarchitecture.net.nz, unfortunately I still get a certificate error if typing www.nzarchitecture.net.nz into a browser - whether this is due to lack of that file, I do not know

2 לייקים

רק מציין שאני מנסה כרגע לגלגל את זה למשתני סביבה כדי לטפל בהם ישירות ב-discourse_docker, משהו כמו רשימה מופרדת בפסיקים של כינויי מארח. נראה כמו מקרה שימוש נפוץ מספיק כדי לטפל בו ישירות.

זה יקל על התצורה למקרה זה, כך שאף אחד לא יצטרך לבצע שינויים ב-app.ymls שלהם.

התוכנית הנוכחית שלי היא עם DISCOURSE_HOSTNAMEwww.domain.com

אפשר סביבה כמו:
DISCOURSE_HOSTNAME_ALIASES: domain.com,other.domain.com ימשוך את התעודה, תקפה לכל שמות המארח.

(בזמן שאני שם, גם חידושי Let’s Encrypt אוטומטיים לא נראים עובדים כראוי, אז אני מתקן גם את אלה)

8 לייקים

זה מדהים! תודה רבה. זה בהחלט יקל על הדברים!

3 לייקים

I missed that! Did as you suggest, but still bootstrap failure:

FAILED

Errno::ENOENT: No such file or directory @ rb_sysopen - /usr/local/bin/letsencrypt
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/replace_command.rb:11:in `read’
replace failed with the params {“filename”=>“/usr/local/bin/letsencrypt”, “from”=>“/-d spokes.nz /”, “to”=>"-d spokes.nz -d www.spokes.nz "}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

Wonderful!!!

3 לייקים

Probably not the central issue here, but in my thrashing about, I also updated the Docker version running on Digital Ocean from 20.0.4 (I think) to 28.3.3 - possibly that helped, at least with this error. If nothing else it did get rid of the docker ‘depreciated’ warnings I was getting at the beginning of the rebuild process.

לייק 1

עליך להסיר את החלק שמנסה לשנות את קובץ ה-lets encrypt ולהמתין לקבלת ה-pr.

2 לייקים

I figured that! Fortunately, I’m on a two container install so that is no big deal.

Any joy with this thusfar?

לייק 1

yep, I’ve got a PR open here pending review:

4 לייקים

היי לכולם, רק עדכון, דומיינים מרובים אוחדו - בגרסה האחרונה של discourse_docker, ניתן כעת לכלול את התבניות ssl ו-letsencrypt ולהגדיר משתני סביבה מהצורה DISCOURSE_HOSTNAME_ALIASES: domain.com,other.domain.com כדי להגדיר שמות מארח חלופיים.

האתר שלכם ימשוך בנוסף את שמות המארח המוגדרים עם בקשת האישור ללא שינויי תצורה נוספים.

4 לייקים

Forgive my ignorance, but is this editable via a site setting anywhere, or does something need to be edited in app.yml?

If the former, I had no luck finding it after updating to the latest, and if the latter, what specifically should be tweaked in app.yml ?

It goes in the app.yml. It’s not handled by Discourse, but by NGINX in the container and it doesn’t have access to the Discourse database.

It goes in the ENV section

env:
   DISCOURSE_HOSTNAME_ALIASES: domain.com,other.domain.com

You’d include only additional domains that you would like for people to be able to link to and be redirected to your site’s actual host name.

3 לייקים

Perfect - all working, thanks!

Would be even better if there was some clever way for discourse to write the aliases supplied by admin to app.yml itself when next updating, or to leave the info where an app.yml instruction can read it.

2 לייקים