From 03be2342d13198ec747d84d91af7f1d60f5e7364 Mon Sep 17 00:00:00 2001 From: jknapp Date: Wed, 23 Jul 2025 19:08:06 -0700 Subject: [PATCH] Enable .htaccess support in Apache container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modified Dockerfile to set AllowOverride All for htdocs directory - Enabled mod_rewrite module for common .htaccess functionality - Added CLAUDE.md with project documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- CLAUDE.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 6 ++++++ 2 files changed, 62 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..18a43f2 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,56 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +This is a Docker-based web server container that provides an Apache HTTP Server with an auto-detection mechanism for web content. If the web directory is empty on startup, it automatically copies a default landing page. + +## Key Architecture + +- **Container Base**: Apache HTTP Server on Alpine Linux (`httpd:alpine`) +- **Startup Logic**: `scripts/startup.sh` handles the auto-detection and default content copying +- **Default Content**: Professional landing page in root `index.html` +- **Web Root**: `/usr/local/apache2/htdocs` inside the container + +## Common Commands + +### Build and Run +```bash +# Build the container +docker build -t my-web-server . + +# Run with default settings +docker run -p 80:80 my-web-server + +# Run with volume mount for custom content +docker run -p 80:80 -v /path/to/web/content:/usr/local/apache2/htdocs my-web-server + +# Run on custom port +docker run -p 8080:80 my-web-server +``` + +### Development +```bash +# View container logs +docker logs + +# Execute shell in running container +docker exec -it /bin/sh + +# Test startup script locally +chmod +x scripts/startup.sh +./scripts/startup.sh +``` + +## Server Deployment + +- The git directory on the servers are /root/whp and once you do a git pull, to sync web files you would run the rsync command for web-files/ to /docker/whp/web/ + +## Important Implementation Details + +1. **Auto-Detection Logic**: The startup script checks if `/usr/local/apache2/htdocs` is empty (ignoring hidden files) before copying default content +2. **Non-Destructive**: Only copies default content if the directory is truly empty - won't overwrite existing files +3. **Startup Flow**: + - Container starts → `startup.sh` runs → Checks for content → Copies if empty → Starts Apache +4. **Default Landing Page**: Responsive, professional design with proper meta tags and CSS \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1ca987b..3e7559b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,11 @@ FROM httpd:alpine +# Enable .htaccess files by modifying Apache configuration +RUN sed -i '//,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /usr/local/apache2/conf/httpd.conf + +# Enable mod_rewrite module (commonly used in .htaccess) +RUN sed -i 's/#LoadModule rewrite_module/LoadModule rewrite_module/' /usr/local/apache2/conf/httpd.conf + # Copy the default landing page to the container COPY index.html /index.html RUN rm -f /usr/local/apache2/htdocs/index.html