Since a few weeks i'm working with Docker/Docker-Compose and Linux.
I'm wondering if it's possible to tune my nginx Performance. All the info I found online where for standard Nginx on Linux and not in a Docker Container.
Here you can see my Docker-Compose and my Nginx default conf.
Maybe you can give me a hint on what I can do better.
Thanks
Docker-Compose----------------------------------------
version: '3.7'
services:
traefik:
image: traefik:v2.4
container_name: traefik
restart: always
security_opt:
- no-new-privileges:true
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./apps/traefik/traefik.yml:/traefik.yml:ro
- ./apps/traefik/acme.json:/acme.json
- ./apps/traefik/configurations:/configurations
networks:
- proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.rule=Host(`traefik.domain.com`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.middlewares=user-auth@file"
nginx:
image: nginx:latest
container_name: nginx
restart: always
volumes:
- ./www:/www
- ./apps/nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
- proxy
- internal
links:
- php-fpm
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.routers.nginx.entrypoints=websecure"
- "traefik.http.routers.nginx.rule=Host(`domain.com`) || Host(`www.domain.com`)"
php-fpm:
image: bitnami/php-fpm:latest
volumes:
- ./www:/www
expose:
- 9000
networks:
- internal
mariadb:
image: mariadb:latest
container_name: mariadb
volumes:
- ./apps/mariaDB/db-data:/var/lib/mysql
networks:
db-net:
internal:
host-network:
ipv4_address: 172.22.0.100
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: db
MYSQL_USER: db-user
MYSQL_PASSWORD: 123
networks:
proxy:
driver: host
external: true
db-net:
internal: true
internal:
internal: true
host-network:
ipam:
driver: default
config:
- subnet: 172.22.0.0/16
Nginx-Conf-----------------------------------------
Server {
server_tokens off;
listen 80;
server_name www.domain.com;
error_log /www/log/error.log;
access_log /www/log/access.log;
root /www;
location / {
index index.php index.html;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
location ~* \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
}