Code Monkey home page Code Monkey logo

docker-static-website's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-static-website's Issues

Hosting behind Traefik under a path prefix

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"

thttpd CGI configuration fails

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.

exec busybox failed

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.

Hide index.html and .html from url?

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:

  1. Hide index.html and just show the domain name
  2. Hide .html from all other URLs.

Is this possible? If so, do you know how?

Thanks in advance!

logi

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

404 page directive not working

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

but 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?

ARM image

It would be great if you can add arm64 image too, thanks.

request: serve static files from a docker volume

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]

simple redirect routing configuration

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!!!! :)

Arm builds?

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.

Add license

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?

Add example docker-compose.yml

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.

File permissions on Windows

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 .

How to echo content into httpd.conf file?

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?

enable gzip compression

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.