Iam using below custom-log-format.conf file for jwilder/nginx-proxy. Everything is working well initially. i can access the nginx and i got all logs in my custom log file,
custom-log-format.conf:
log_format vhost '$remote_addr - $remote_user $time_iso8601 [$request_time] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
$remote_user $time_iso8601 [$request_time] ;
access_log /var/log/nginx/access_custom.log vhost;
But when i restart the container i got duplicate log_format error in nginx container. My only problem is when i restart the container i got the duplicate error. Otherwise when i start the container with the below command, it is working good.
Error:
nginx.1 | 2025/10/24 06:36:15 [emerg] 321#321: duplicate "log_format" name "vhost" in /etc/nginx/conf.d/default.conf:72
nginx.1 | nginx: [emerg] duplicate "log_format" name "vhost" in /etc/nginx/conf.d/default.conf:72
forego | starting nginx.1 on port 34700
nginx.1 | 2025/10/24 06:36:15 [emerg] 322#322: duplicate "log_format" name "vhost" in /etc/nginx/conf.d/default.conf:72
nginx.1 | nginx: [emerg] duplicate "log_format" name "vhost" in /etc/nginx/conf.d/default.conf:72
forego | starting nginx.1 on port 34800
Command:
docker run -d -p 80:80 -p 443:443 --name nginx-proxy --network nginx-proxy -v /mnt/certs:/etc/nginx/certs -v /mnt/agent_deploy.sh:/usr/local/agent_deploy.sh -v /var/run/docker.sock:/tmp/docker.sock:ro -v /mnt/ApplicareSingleAgentLinux:/usr/local/ApplicareSingleAgentLinux -v /mnt/custom-log-format.conf:/etc/nginx/conf.d/custom-log-format.conf:ro --hostname nginx jwilder/nginx-proxy
I tried the log_format and access_log name in custom-log-format.conf file from vhost to custom_vhost but if i changed that name the nginx is not working when i start the container initially, i got 503 error on container.
Please help me to resolve that issue.