===== Web upload =====
services:
upload:
build: ./
container_name: upload
volumes:
- /mnt/images:/var/www/uploads
labels:
- "traefik.enable=true"
- "traefik.http.routers.upload.rule=Host(`upload.example.ca`)"
- "traefik.http.routers.upload.entrypoints=websecure"
- "traefik.http.routers.upload.tls=true"
- "traefik.http.routers.upload.tls.certresolver=letsencrypt"
- "traefik.http.services.upload.loadbalancer.server.scheme=http"
- "traefik.http.services.upload.loadbalancer.server.port=80"
- "traefik.http.services.upload.loadbalancer.responseForwarding.flushInterval=500ms"
networks:
- web
networks:
web:
external: true
FROM php:8.2-fpm-alpine
# Install necessary PHP extensions
RUN docker-php-ext-install pdo pdo_mysql
# Configure PHP settings
RUN echo "upload_max_filesize = 10240M\npost_max_size = 10240M\nmax_execution_time = 300\nmax_input_time = 300" > /usr/local/etc/php/conf.d/uploads.ini
# Create uploads directory and set permissions for www-data user
RUN mkdir -p /var/www/uploads && chown -R www-data:www-data /var/www/uploads && chmod -R 775 /var/www/uploads
# Set the working directory
WORKDIR /var/www/html
# Copy your application files (example)
COPY . /var/www/html
# Expose the port
EXPOSE 9000
# Start PHP-FPM service
CMD ["php-fpm"]
Upload
Upload a file (up to 10GB)
worker_processes 1;
events { worker_connections 1024; }
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 10G;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
root /var/www/html;
location / {
index index.php;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
}
}
}
openssl passwd -apr1 MyPassword123!
user1:
user2:
user3: