#The default server configuration file
server {
        listen ${MAIN_IP}:80 default_server;
        listen 80 default_server;
	server_name _;
	server_name_in_redirect off;
        access_log off;
        location / {
           proxy_send_timeout   90;
           proxy_read_timeout   90;
           proxy_buffer_size    4k;
           proxy_buffers     16 32k;
           proxy_busy_buffers_size 64k;
           proxy_temp_file_write_size 64k;
           proxy_connect_timeout 30s;
           proxy_pass   http://127.0.0.1:${APACHE_HTTP_PORT};
           proxy_set_header   Host   $host;
           proxy_set_header   X-Real-IP  $remote_addr;
           proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
          }
}

server {
        listen ${MAIN_IP}:443 default_server ssl http2;
        listen 443 default_server ssl http2;
	server_name _;
	server_name_in_redirect off;
        ssl_certificate /var/cpanel/ssl/cpanel/${CPSSL};
        ssl_certificate_key /var/cpanel/ssl/cpanel/${CPSSL};
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout  5m;
        access_log off;
        location / {
           proxy_send_timeout   90;
           proxy_read_timeout   90;
           proxy_buffer_size    4k;
           proxy_buffers     16 32k;
           proxy_busy_buffers_size 64k;
           proxy_temp_file_write_size 64k;
           proxy_connect_timeout 30s;
           proxy_pass   https://127.0.0.1:${APACHE_HTTPS_PORT};
           proxy_set_header   Host   $host;
           proxy_set_header   X-Real-IP  $remote_addr;
           proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
          }
}

server {
        listen ${MAIN_IP}:80 ;
        listen 80 ;
        server_name cpanel.* whm.* webmail.* webdisk.* cpcalendars.* cpcontacts.* mail.*;
        server_name_in_redirect off;
        access_log off;
        location / {
            proxy_pass   http://127.0.0.1:${APACHE_HTTP_PORT};
            proxy_set_header   Host   $host;
            proxy_set_header   X-Real-IP  $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}


server {
        listen ${MAIN_IP}:443 ssl http2 ;
        listen 443 ssl http2 ;
        server_name cpanel.* whm.* webmail.* webdisk.* cpcalendars.* cpcontacts.* mail.*;
        server_name_in_redirect off;
        ssl_certificate /var/cpanel/ssl/cpanel/${CPSSL};
        ssl_certificate_key /var/cpanel/ssl/cpanel/${CPSSL};
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout  5m;
        access_log off;
        location / {        
            proxy_pass   https://127.0.0.1:${APACHE_HTTPS_PORT};
            proxy_set_header   Host   $host;
            proxy_set_header   X-Real-IP  $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}
