LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-17-2024, 06:27 AM   #1
glennbtn
Member
 
Registered: Dec 2009
Posts: 154

Rep: Reputation: 19
docker, ntfy and https


Hi All

I am quite new to docker so just trying to get my head around things. I have install NTFY which works fine over port 80 but can't get https to work.

I have installed certbot and obtained a certificate. I have edit the yaml file

listen-http: ":80"
listen-https: ":443"
key-file: "/etc/letsencrypt/live/docker.mydomain.co.uk/privkey.pem"
cert-file: "/etc/letsencrypt/live/docker.mydomain.co.uk/cert.pem"

but the container won't now run and when you view the log it just says if set, key file must exist

Any pointer would be great, thanks
 
Old 04-21-2024, 07:10 AM   #2
dionbl
LQ Newbie
 
Registered: Apr 2024
Location: Auckland, NEW ZEALAND
Distribution: Debian (latest stable version)
Posts: 2

Rep: Reputation: 1
I had the same issue.

"if set, key file must exist"
essentially means either the files don't exist (which they do), or they can't be read due to permissions (which is the case)

When I started it using:

sudo ntfy serve

it would work.

But

sudo service ntfy start

would not work.

And that is because on debian, it runs as user ntfy when started as a service

Turns out it was a permissions problem and I needed the user ntfy to be able to read the files.

So it did this:

sudo chmod -R 644 /etc/letsencrypt
sudo chmod -R +X /etc/letsencrypt

And now it works.

You might wish to be more careful with permissions and you could

chown root:ntfy

to the relevant files/directories

and

chown 640

to the relevant files, to be more secure.
 
Old 04-22-2024, 08:01 AM   #3
TomF247
LQ Newbie
 
Registered: Apr 2024
Posts: 2

Rep: Reputation: 0
I too am having exactly this same issue.I am running NTFY in a docker container and all works well while using http. It's picking up the options from my host server.yml file just fine.

When I set the options for https in server.yml I get the "if set, key file must exist" error. Needless to say they are created and present, but no matter what permissions I set on them nothing seems to work. In Docker, the container runs under the user 'ntfy'. This user does not exist on the host. I've created a user 'nfty' on the host, but I still get the same error.

From my google searches I see examples of changing the owner of the certificates and folders to ntfy on the host, but so far I've had no success. If there is a sample server.yml (just to compare) with that of my own, or perhaps an ls-l of the permissions of an actual working certificate configuration I'd be very appreciative.

Or anything further that you think I may be overlooking.

Many thanks.
 
Old 04-22-2024, 08:17 AM   #4
glennbtn
Member
 
Registered: Dec 2009
Posts: 154

Original Poster
Rep: Reputation: 19
Ah now that makes sense

Thanks for taking the time to come back to me on this
 
Old 04-23-2024, 12:12 AM   #5
dionbl
LQ Newbie
 
Registered: Apr 2024
Location: Auckland, NEW ZEALAND
Distribution: Debian (latest stable version)
Posts: 2

Rep: Reputation: 1
Quote:
Originally Posted by TomF247 View Post
I am running NTFY in a docker container and all works well while using http.
I'm not very familiar with docker. My questions to you are:
1) have you copied the folder /etc/letsencrypt to your docker container. If not do this
2) another option would be to run letsencrypt from your docker container

My guess, would be that you have the files on your host, but not in the container.

Hope this helps.
 
1 members found this post helpful.
Old 04-23-2024, 02:15 AM   #6
glennbtn
Member
 
Registered: Dec 2009
Posts: 154

Original Poster
Rep: Reputation: 19
Yes you keep the letsencrypt on the host and then make sure when you start the docker it has a mapping. If you put them on the container they will be lost when you stop the container.

Code:
docker run \
-v /var/cache/ntfy:/var/cache/ntfy \
-v /etc/ntfy:/etc/ntfy \
-v /etc/letsencrypt:/etc/letsencrypt
-p 443:443 \
-itd \
binwiederhier/ntfy \
serve \
--cache-file /var/cache/ntfy/cache.db
 
1 members found this post helpful.
Old 04-23-2024, 02:40 PM   #7
TomF247
LQ Newbie
 
Registered: Apr 2024
Posts: 2

Rep: Reputation: 0
Dionbl & Glennbtn,

I am forever grateful. Between both pieces of advice I got it to work. With your assistance I learned something valuable and I won't forget!

Many thanks,

Tom
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to install and self host an Ntfy server on Linux LXer Syndicated Linux News 0 07-01-2023 10:03 AM
LXer: Difference between docker.io, docker-cd, and Docker Desktop LXer Syndicated Linux News 0 08-15-2022 05:39 PM
What are the best ways and practices to manage local SSL certificates with my own CA, to get local HTTPS sites like https://testsite.local ? ZhaoLin1457 Slackware 11 02-04-2021 04:15 PM
LXer: What is https and How to enable https on your website LXer Syndicated Linux News 1 11-26-2019 06:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration