Skip to content

FEATURE: Move letsencrypt scripts to work on boot #977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 25, 2025

Conversation

featheredtoast
Copy link
Member

Allows ssl and letsencrypt templates to run on boot via initscripts

This change adds the decision to configure https or letsencrypt to be at runtime
rather than at build time via env vars.

Under the hood, these are the commands, just migrated to shellscripts
that run when a container boots.

Runs on existence of ENABLE_SSL (base ssl template)
or LETSENCRYPT_ACCOUNT_EMAIL (ssl template+letsencrypt template)

Both cases checks and errors on blank hostname.

@featheredtoast
Copy link
Member Author

featheredtoast commented Jul 16, 2025

One complication to note, is moving the configuration out to boot like this breaks some assumptions (that the ssl configuration is available at build time) for the socketed template.

Perhaps it would be better to have these available as new templates?

Alternatively, it might be sufficient as-is as web.socketed.template is usually used for folks running their own proxies+ssl termination, so perhaps it makes sense that the ssl.templates and socketed.template are mutually exclusive?

@pfaffman
Copy link
Contributor

pfaffman commented Jul 16, 2025 via email

@featheredtoast
Copy link
Member Author

@pfaffman that same concern exists in the current templates already - the current templates also have to grab templates on boot already.

I'm not changing how the ssl cert is attained, just making it so things also can get configured at boot.

@pfaffman
Copy link
Contributor

Agreed. The current way you get rate limited building a container. The proposed way you get rate limited running a container. They are both bad. Maybe the new way is better?

@featheredtoast
Copy link
Member Author

No, what I mean is both the old and proposed way here request the cert on container boot here:

This proposal doesn't change anything about when that's done.

Allows ssl and letsencrypt templates to run on boot via initscripts

This change adds the decision to configure https or letsencrypt to be at runtime
rather than at build time via env vars.

Under the hood, these are the commands, just migrated to shellscripts
that run when a container boots.

Runs on existence of ENABLE_SSL (base ssl template)
or LETSENCRYPT_ACCOUNT_EMAIL (ssl template+letsencrypt template)

Both cases checks and errors on blank hostname.
contents: |
EOF

> /etc/nginx/conf.d/outlets/server/10-http.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This redirection is non-idiomatic. Use touch or install /dev/null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of this line is to empty the file. I've updated to use install /dev/null - thanks for the pointer!

Copy link
Member

@andrewschleifer andrewschleifer Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, that was a possibility I had not considered. echo > $FILE is the normal way to do that, sorry. (Possibly with a comment to explain that it already exists and we want to wipe out the contents.)

split up if statements. Add spaces around heredoc.
use install /dev/null rather than empty redirect to clear a file.
@featheredtoast featheredtoast merged commit c9064be into main Jul 25, 2025
5 checks passed
@featheredtoast featheredtoast deleted the runtime-letsencrypt branch July 25, 2025 06:01
@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/connection-refused-on-self-hosted-instance-after-rebuild/376224/2

@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/no-secure-connection-to-self-hosted-discourse-after-latest-update/376163/8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants