From 2d90d40b3a0e096d2cd26891f7bb817d0e399467 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Mon, 7 Jul 2025 23:54:00 +0900 Subject: [PATCH] Simplify to minimal nginx proxy setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use standard nginx:alpine image instead of custom build - Simple default.conf for 80 → 5137 proxy - Remove unnecessary nginx/ directory and complex configurations - Clean, minimal setup for basic reverse proxy 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- default.conf | 10 +++++ docker-compose.yml | 13 +++---- nginx/Dockerfile | 21 ---------- nginx/nginx.conf | 96 ---------------------------------------------- 4 files changed, 15 insertions(+), 125 deletions(-) create mode 100644 default.conf delete mode 100644 nginx/Dockerfile delete mode 100644 nginx/nginx.conf diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..0a4ec7a --- /dev/null +++ b/default.conf @@ -0,0 +1,10 @@ +server { + listen 80; + + location / { + proxy_pass http://127.0.0.1:5137; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index d866679..32c92b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,10 @@ -version: '3.8' +version: "3.8" services: nginx: - build: ./nginx + image: nginx:alpine ports: - "80:80" - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost/health"] - interval: 30s - timeout: 10s - retries: 3 \ No newline at end of file + volumes: + - ./default.conf:/etc/nginx/conf.d/default.conf:ro + restart: always \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile deleted file mode 100644 index 918777a..0000000 --- a/nginx/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM nginx:1.25-alpine - -# Copy custom nginx configuration -COPY nginx.conf /etc/nginx/nginx.conf - -# Create log directory -RUN mkdir -p /var/log/nginx - -# Set proper permissions -RUN chown -R nginx:nginx /var/log/nginx -RUN chown -R nginx:nginx /var/cache/nginx - -# Add healthcheck -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD curl -f http://localhost/health || exit 1 - -# Expose port -EXPOSE 80 - -# Start nginx -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf deleted file mode 100644 index f892a48..0000000 --- a/nginx/nginx.conf +++ /dev/null @@ -1,96 +0,0 @@ -user nginx; -worker_processes auto; -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - - # Gzip compression - gzip on; - gzip_vary on; - gzip_min_length 1024; - gzip_types - text/plain - text/css - text/xml - text/javascript - application/json - application/javascript - application/xml+rss - application/atom+xml - image/svg+xml; - - # Upstream servers - upstream api_backend { - server api-base:8000; - server test_api:8001; - } - - upstream frontend_backend { - server host.docker.internal:5137; - } - - # Main server block - server { - listen 80; - server_name localhost; - - # Frontend routing - location / { - proxy_pass http://frontend_backend; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - - # API routing - location /api/ { - proxy_pass http://api_backend/; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - # CORS headers - add_header 'Access-Control-Allow-Origin' '*' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always; - - if ($request_method = 'OPTIONS') { - return 204; - } - } - - # Health check endpoint - location /health { - access_log off; - return 200 "healthy\n"; - add_header Content-Type text/plain; - } - - # Static files caching - location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - } - } -} \ No newline at end of file