Closed m3xw3ll closed 2 years ago
Try running it with '-it' instead of '-d' to see if there is any output from the container (if it runs you can exit with ctrl+c). Is it returning immediately with/without an error or what are you seeing? It may also be worth added '-e DEBUG=true' to get some debug output (or set it true in your YAML. Otherwise, can you upload the YAML file so I can see everything, including the whitespace in the file?
Thank you for your quick reply. I tried running it with '-it' and set debug to true in the YAML config.
I get following error message while starting:
2022/01/11 06:45:46 Error: read HalverneusConfig.yml: is a directory
I checked the YAML with the YAML Validator. Everything is valid.
Here is a zip with the YML file just in case.
HalverneusConfig.zip
There seems to be some differences between running it on your system and running it on mine. I can get past the part of loading the config file:
docker run -it -v /src:/web -v ${PWD}/HalverneusConfig.yml:/HalverneusConfig.yml -p 8088:8080 halverneus/static-file-server:latest -c HalverneusConfig.yml
2022/01/11 15:45:40 Error: value of TLS_CERT is set with filename 'certificate.crt' that returns stat certificate.crt: no such file or directory
That tells me that the config file is being loaded on my machine (I just don't have any certificates mounted in my container). Is the HalverneusConfig.yml
actually in the root of your file system? I notice when I point the command (like the command you shared) to the root of the filesystem rather than the current directory (where the config file actually is) that I get the same error:
docker run -it -v /src:/web -v /HalverneusConfig.yml:/HalverneusConfig.yml -p 8088:8080 halverneus/static-file-server:latest -c HalverneusConfig.yml
2022/01/11 15:47:52 Error: read HalverneusConfig.yml: is a directory
(BTW, the port is only different because I'm using port 8080 on my host, already.) I'm guessing that the command you really want is actually:
docker run -it -v ${PWD}/certs:/certs -v ${PWD}/src:/web -v ${PWD}/HalverneusConfig.yml:/HalverneusConfig.yml -p 8088:8080 halverneus/static-file-server:latest -c HalverneusConfig.yml
(assuming your certificates on in a local ./certs
folder)
First of all I noticed I made a terrible mistake. I forgot the 'dot' before /HalverneusConfig.yml
. So I guess this was the problem
which throws the Error: read HalverneusConfig.yml: is a directory
error. All my project files are stored in ./data/<myproject>/
including the HalverneusConfig.yml and cert/key files. Is it neccessary to create a ./certs folder and copy the cert and pem files into it rather than saving them in my project directory?
EDIT: I created a certs folder in the root directory and ran your code. I get the error:
2022/01/12 09:28:03 Error: value of TLS_CERT is set with filename 'stat ./mycrt.crt: no such file or directory' that returns %!v(MISSING)
BTW, I´m pretty new to docker so that means the ${PWD} in your snippets? If I copy the cert/pem files into the ./certs folder, do I have to make some changes in the yml file?
I don't know if Docker can do this, now, but, historically, when connecting to volumes you need to use full absolute paths (hence ${PWD} vs just ./). I'm waiting this on my phone, now, but I seem to remember your configuration looking for certificates in the root of the filesystem, which would mean that your would need to pass in each file as a volume individually. To get you started, try this:
/path/to/project/config/config.yml /path/to/project/config/my.key /path/to/project/config/my.crt /path/to/project/src/...
Update your config.yml to find your certs in: /config/my.key /config/my.crt
From the /path/to/project directory run:
docker run -it -v ${PWD}/src:/web -v ${PWD}/config:/config -p 8080:8080 halverneus/static-file-server:latest -c /config/config.yml
You won't want your certificates in the same files being served by the static file server (/web) because that means someone will be able to download them and trick your users by appearing trusted. Does that work (and make sense)?
Okay I made the changes and tried to start the container with the command you provided. It seems that the container is running with SSL now. But with which URL I can access the files stored in /path/to/project/src/?
It should work with https://<myserver>:8080/web
right? But I get a 404 HTTP error for this URL.
Skip the /web
portion. If you have the following file:
/path/to/project/src/index.html
and you have it mapped like the last command I shared, then this will download it:
https://
Assuming you don't disable the feature, just going to https://
I just connected to the server and tried to access https://8080
via browser but I get the 'unable to connect' error.
It is also important to mention that I want access from clients to the content in the /src directory, not only from the server itself.
The last few hours I spend some times to get things done and so far I found a way to get access to the content on the server via my client computer.
I started to docker via sudo docker run -it -v /data/rasa/src:/web -v /data/rasa/config:/config -p 8080:8080 halverneus/static-file-server:latest -c /config/config.yml
btw. my projectfolder is called rasa Now I can access the content via http://MYSERVER:8080/MYFILE
The command line logs showed this message after I started the docker:
Using the following configuration:
cors: true
debug: true
folder: /data/rasa/src
host: ""
port: 8080
show-listing: true
tls-cert: config/<mycert>
tls-key: config/<mypem>
url-prefix: ""
referrers: []
So it seems I successfully loaded the config into the docker. But if I try to access https://404 error
.
So, you are saying that, with the same configuration and no changes that this URL returns a file:
http://myserver:8080/myfile
but this URL gives a 404:
https://myserver:8080/myfile
and there is no difference in your configuration? Is that correct? Or in the first one you are leaving out tls-cert and tls-key and adding it back in for the second one?
Sorry I just double checked it. I´m getting more and more confused because I can´t get things done.
http://<myserver>:8080/myfile
returns Client sent an HTTP request to an HTTPS server.
https://<myserver>:8080/myfile
returns 404 page not found
Meanwhile in the console
2022/01/20 06:28:40 REQ from '<ipaddress>:62504': GET HTTP/2.0 <myserver>:8080/ -> /data/rasa/src/
2022/01/20 06:28:40 REQ from '<ipaddress>:62504' (REFERER: 'https://<myserver>:8080/'): GET HTTP/2.0 <myserver>:8080/favicon.ico -> /data/rasa/src/favicon.ico
2022/01/20 06:34:10 REQ from '<ipaddress>:62504': GET HTTP/2.0 <myserver>:8080/jokes.txt -> /data/rasa/src/jokes.txt
Oh! I see the issue, now! In your Docker command you map your folder /data/rasa/src to /web, but you also configure the server to look for files in /data/rasa/src rather than where they are actually mapped (/web). You need to do one or the other, not both. I recommend leaving your Docker command alone and just removing the folder from the server's configuration so it defaults to looking in /web.
Yes, that was the problem. I removed the folderpath in the config.yml
and started the container with the command above.
Now I can access the files. Thank you very much!
Hello,
I need to pass a YML-file to specify my SSL parameters. Here is the file
and i try to run the docker with following command as suggested here:
sudo docker run -d -v /src:/web -v /HalverneusConfig.yml:/HalverneusConfig.yml -p 8080:8080 halverneus/static-file-server:latest -c HalverneusConfig.yml
But the docker container won´t start. If i check via
sudo docker container ls
i get an empty result. Where is the mistake in my configuration?