• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Nginx configuration for 1000 domains

stas styler

Basic Pleskian
Hi pleskians,

I'm having trouble with my server its getting 504\2 too often and I assume that the nginx.conf is the problem.
But i cant find it.

My server is 48 cores 128 GB ram with NVME 2tb, running centos7, nginx as reversed proxy and apache, 1gbit/s link.
this is my nginx.conf
Code:
#user  nginx;
worker_processes  48;
worker_rlimit_nofile 49152;
#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections 24576;
    multi_accept on;
    use epoll;
}


http {

include       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  /dev/null;
    error_log   /dev/null;
    keepalive_timeout  15;
    server_tokens off;
    open_file_cache          max=10000 inactive=20s;
    open_file_cache_valid    30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors off;
    client_body_buffer_size 128K;
    client_header_buffer_size 1k;
    client_max_body_size 8m;
    large_client_header_buffers 4 256k;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_connect_timeout 600;
    fastcgi_send_timeout 600;
    fastcgi_read_timeout 600;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    client_header_timeout 15;
    client_body_timeout 15;
    send_timeout 15;
    autoindex off;


    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;


I'm trying to make that to work good but unfortunatelly i'm having problems.
I got 200 domains currently, some are high traffic, some are not (AVG 700Packets/s).

Is my nginx.conf configured somehow bad so its just timing out and crashes?
 
Well there are a lot of possabillitys which can cause the 504 & 502 messages, even if you search the forum for "Nginx 502 or 504", you will find dozens of threads. I assume you are you talking about this error on customer domains?

therefore you also should check the /var/log/nginx/error.log and /var/www/vhosts/system/example.com/logs/proxy_error_log for detailed error message. Helpfull is also when you provide OS & plesk version you have.

see for example:
[HUB] 502 Bad Gateway
A website is not accessible with "Nginx 504 Gateway Time-out": upstream timed out (110: Connection timed out) while reading response header from upstream
Websites are unavailable with 502 Bad Gateway on Plesk: upstream sent too big header while reading response header
 
Last edited:
Back
Top