lipanski / docker-static-website Goto Github PK
View Code? Open in Web Editor NEWA very small Docker image (~80KB) to run any static website
License: MIT License
A very small Docker image (~80KB) to run any static website
License: MIT License
I tried to implement the E404 directive but I can't make it work.
My starting point was: https://github.com/lipanski/docker-static-website#how-can-i-overwrite-the-default-error-pages
Repo where I tried to implement it:
https://github.com/nexys-system/boilerplate_vite
Dockerfile
: https://github.com/nexys-system/boilerplate_vite/blob/master/Dockerfilehttpd.conf
: https://github.com/nexys-system/boilerplate_vite/blob/master/httpd.confbut when I start the container I get the following warnings:
2022-08-08T15:12:14.754050482Z httpd: config error 'E404:/home/static/index.html' in 'httpd.conf'
2022-08-08T15:12:14.754090667Z httpd: config error 'E404:index.html' in 'httpd.conf'
Note that when I use basic auth or the I
directive, the httpd.conf
is interpreted and I see the expected results.
I also looked into the busybox source code but, unless ENABLE_FEATURE_HTTPD_ERROR_PAGES
is disabled (which I don't think it is see here), it should be ok
Any ideas?
Hello,
First of all, thank you very much for putting this image together! So far it works great with my static website. There are only two things that I was hoping I could do:
index.html
and just show the domain name.html
from all other URLs.Is this possible? If so, do you know how?
Thanks in advance!
I am trying to open .txt files with special characters. The problem is that they are not properly encoded in utf-8. How can I change this behavior?
expected behavior: https://pastebin.com/raw/H3aaj6zq
I've tried to enable serving of static files from a docker volume (i.e. --volume ./public:/public_html:ro
) by adding a httpd.conf to my root folder with H:/public_html
in it).
I also changed the Dockerfile to include CMD ["/busybox", "httpd", "-f", "-v", "-p", "3000", "-c", "httpd.conf"]
For some reason no files get served, all I get is a 404 error. Frankly I have run out of ideas how to test what is wrong.
I'm sure it is an error on my side but would it be possible to have a look into this? It would make changes to content much easier since it wouldn't require a container restart.
[edit to mention change of Dockerfile]
.git directory should be disabled by default.
For easier use, I always use docker compose
. Might be helpful for other users to ship or have an example docker-compose.yml
file.
#23 does that.
I have a small website and I love that.
However, I want to serve a PDF file as well.
Right now, the PDF file is not being served with correct mime type causing the browsers to display garbled output.
Hey,
thank you very much for this minimal Docker image. I would like to ask if you could add a license (e.g. MIT or GPL) to the repository?
When trying to serve image files, I'm getting 403 errors because of the CGI security setting in THTTPD. The documentation says it is possible to specify a different CGI_PATTERN from the command line using the '-c' option, which I'm doing as follows:
FROM lipanski/docker-static-website:latest
# Copy your static files
COPY . .
CMD ["/thttpd", "-D", "-h", "0.0.0.0", "-p", "3000", "-d", "/home/static", "-u", "static", "-l", "-", "-M", "60", "-c", "\"**.png\"']
I've tried different variations of this approach, but nothing works.
I've also gone as far as replacing the "config.h" file prior to thttpd compilation in the base image to #define the CGI_PATTERN directly in the binary image, but nothing seems to work.
Hi, I have the following Dockerfile:
FROM lipanski/docker-static-website:2.1.0
RUN echo "E404:index.html" > httpd.conf
COPY --from=build /app/dist/frontend .
I get the following error when I try to echo the content of the httpd.conf file:
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory: unknown
How can I do this properly?
I have a docker-compose config similar to this:
invoices:
image: lipanski/docker-static-website:latest
volumes:
- "/root/generate-invoices:/home/static"
labels:
- "traefik.enable=true"
- "traefik.http.routers.invoices.rule=(Host(`my-host.com`) && PathPrefix(`/invoices/`))"
- "traefik.http.middlewares.strip-invoices.stripprefix.prefixes=/invoices"
- "traefik.http.routers.invoices.middlewares=strip-invoices@docker"
- "traefik.http.routers.invoices.entrypoints=websecure"
- "traefik.http.routers.invoices.tls.certresolver=myresolver"
This allows my to go to https://my-host.com/invoices to see the file list served by docker-static-website. An issue with this is however that the hyperlinks in the file list are absolute and not relative to the path. A file named "fileA" will link to https://my-host.com/fileA rather than to https://my-host.com/invoices/fileA.
Looking at the config options for thttpd there isn't an option to make these links relative of specify a base path.
A workaround I found was to mount my volume under a subdirectory matching the base path I want. Ex:
invoices:
image: lipanski/docker-static-website:latest
volumes:
- "/root/generate-invoices:/home/static/invoices"
labels:
- "traefik.enable=true"
- "traefik.http.routers.invoices.rule=(Host(`my-host.com`) && PathPrefix(`/invoices/`))"
- "traefik.http.routers.invoices.entrypoints=websecure"
- "traefik.http.routers.invoices.tls.certresolver=myresolver"
would it be possible to provide a simplified configuration for redirect routing?
/ ---> /index.html
/index --> index.html
/pippo --> index.html
/something-else ---> other.html
or maybe an example of how to do this with a simple httpd.conf ? this image is awesome!!!! :)
Wydaje się, że warto było by gdzieś na zewnatrz kontenera przechowywac logi.
Nawet by zobaczyć czy ktos nie próbuje się włamać.
Druga sprawa to benchmark. Przy uruchomieniu na małym sprzęcie np. raspberry pi zero zasoby nie tylko pamięci ale i cpu mogą byc istotne.
No i kwestia zwiększenia ilości serwerów (loadbalancing) przy wiekszej ilości maszyn. trzeba jednak zrobić parę kontenerów i zapuścić sprawdzanie wydajności
Or command line.
Having to replicate the whole command line just to change the path is ugly :(
Hello not sure if we can use this CMD on 2.3.0?
FROM lipanski/docker-static-website:2.3.0
ARG PUBLIC_URL /.
COPY --from=build /tmp/app/httpd.conf .
COPY --from=build /tmp/app/dist/ .$PUBLIC_URL
CMD ["/busybox", "httpd", "-f", "-v", "-p", "80", "-c", "httpd.conf"]
EXPOSE 80
[FATAL tini (7)] exec /busybox failed: No such file or directory
ELIFECYCLE Command failed.
https://github.com/krallin/tini
# add sigterm and sigkill listen
RUN apk add --no-cache tini
WORKDIR /app
RUN chown -R node /app
USER node
#then not sure how you run the rest but ...
CMD [ "/sbin/tini", "--", "......entrypoint" ]
Hi
when I make a default (index) file, naming it "default.htm" and add:
I:default.htm
to "httpd.conf", and restarting the service, it won't work, and will encounter the default error again!
It would be great if you can add arm64 image too, thanks.
I am using the image from a windows machine and I noticed that every file is copied with the executable attribute set to true. This causes thttpd to treat it as a CGI file and therefore it fails to serve even simple HTML pages. Even with the recently added chmod option of COPY command is not possible to correctly copy folders inside the container.
I am leaving this issue to help others that might face the same problem. My workaround is to leverage on an alpine build stage that correctly setups file attributes:
FROM alpine:latest as base
WORKDIR /app
COPY . .
RUN chmod -R -x+X .
RUN ls -l
FROM lipanski/docker-static-website:latest
COPY --from=base /app .
I think this project is great!
I was wondering if you were thinking of adding gzip support? (something that I currently do in Nginx but it would be great if it'd work with this project - much smaller docker file size)
This is a super convenient container - but ran into it arm builds not being available for raspberry pi. Any chance you'd have interest in including arm builds here? I can of course rebuild it locally, but it'd be nice to keep things together under the existing locations.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.