{"id":2312,"date":"2023-07-19T14:11:59","date_gmt":"2023-07-19T14:11:59","guid":{"rendered":"https:\/\/www.qworqs.com\/?p=2312"},"modified":"2024-10-14T02:15:53","modified_gmt":"2024-10-14T02:15:53","slug":"nginx-common-tweaks","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2023\/07\/19\/nginx-common-tweaks\/","title":{"rendered":"NGINX &#8211; Common tweaks"},"content":{"rendered":"\n<p>if you are processing data with nginx and PHP-FPM, you might want to increase the following<\/p>\n\n\n\n<p>\u201c504 Gateway Timeout\u201d is when nginx is waiting for a response from php-fpm for too long, you can fix that with<\/p>\n\n\n\n<p>Increase PHP maximum execution time in \/etc\/php.ini:&nbsp;max_execution_time = 300<br>Increase PHP-FPM request terminate timeout in the pool configuration (\/etc\/php\/8.2\/fpm\/pool.d\/www.conf):&nbsp;request_terminate_timeout = 300<\/p>\n\n\n\n<p>To disable all timeouts&#8230; you can add the following into any context, for serverwide, add anywhere in the http context (in \/etc\/nginx\/nginx.conf)<br><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">keepalive_timeout 1d;\nsend_timeout 1d;\nclient_body_timeout 1d;\nclient_header_timeout 1d;\nproxy_connect_timeout 1d;\nproxy_read_timeout 1d;\nproxy_send_timeout 1d;\nfastcgi_connect_timeout 1d;\nfastcgi_read_timeout 1d;\nfastcgi_send_timeout 1d;\n#memcached_connect_timeout 1d;\n#memcached_read_timeout 1d;\n#memcached_send_timeout 1d;<\/pre>\n\n\n\n<p>Increasing php fpm values<\/p>\n\n\n\n<p>Before you change values in php.ini, you need to tweak nginx a bit, so you need to start by editing the nginx config file at \/etc\/nginx\/nginx.conf, and at the bottom of the http block, you may want to do the following<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">client_max_body_size 150m;<br>client_body_timeout 120;<\/pre>\n\n\n\n<p>Now, the above should be higher than the php max upload and max post sizes, if you like, you can disable the nginx restriction by setting them to zero !<\/p>\n\n\n\n<p>Now, go for your php file that you can find in a place such as (\/etc\/php\/8.2\/fpm) and edit the values, for example<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">upload_max_filesize = 150M<br>post_max_size = 150M<\/pre>\n\n\n\n<p>Once done, dont forget to restart both<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart php8.2-fpm<br>systemctl restart nginx<br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>if you are processing data with nginx and PHP-FPM, you might want to increase the following \u201c504 Gateway Timeout\u201d is when nginx is waiting for a response from php-fpm for too long, you can fix that with Increase PHP maximum execution time in \/etc\/php.ini:&nbsp;max_execution_time = 300Increase PHP-FPM request terminate timeout in the pool configuration (\/etc\/php\/8.2\/fpm\/pool.d\/www.conf):&nbsp;request_terminate_timeout [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[170,169],"tags":[],"class_list":["post-2312","post","type-post","status-publish","format-standard","hentry","category-nginx","category-web-servers"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/2312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=2312"}],"version-history":[{"count":7,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/2312\/revisions"}],"predecessor-version":[{"id":4020,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/2312\/revisions\/4020"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=2312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=2312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=2312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}