api platform getting 502 bad gateway during https://localhost:8443/ browse - php

I am running api-platfor version 2.5 with docker after run it and browse https://localhost:8443/. I am getting 502 bad gateway error. here is my error in terminal
api_1 | 2019/11/03 03:57:11 [error] 7#7: *1 connect() failed (111: Connection refused) while connecting to upstream, client:
172.18.0.7, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.5:9000", host: "api"
can you let me know please how can i solve it

Related

Get CannotWriteFileException when upload 120mb file on nginx server

I have a Laravel 7 project on the Ubuntu + Nginx server. I can upload files less than ~10mb, but when i am trying to upload a 120mb file I got an error. I am already changed memory_limit, upload_max_filesize, post_size to 640mb in php.ini. It did not help. I am also restart php-fpm and nginx services.
ERROR LOG
2021/01/21 21:11:51 [warn] 13069#13069: *1 a client request body is
buffered to a temporary file /var/lib/nginx/body/0000000001, client: 92.47.198.158, server: servername, request: "POST /courseclass/17 HTTP/2.0", host: "servername", referrer: "https://servername/courseclass/17"
2021/01/21 21:11:53 [error] 13069#13069: *1 openat() "/var/www/servername/video/class/video_course_1611240590.mp4" failed (2: No such file or directory), client: 92.47.198.158, server: servername, request: "GET /video/class/video_course_1611240590.mp4 HTTP/2.0", host: "servername", referrer: "https://servername/watch/course/6"
2021/01/21 21:11:54 [error] 13069#13069: *1 openat() "/var/www/servername/video/class/video_course_1611240590.mp4" failed (2: No such file or directory), client: 92.47.198.158, server: servername, request: "GET /video/class/video_course_1611240590.mp4 HTTP/2.0", host: "servername", referrer: "https://servername/watch/course/6"
2021/01/21 21:41:18 [error] 13069#13069: *8 openat() "/var/www/servername/images/light.jpg" failed (2: No such file or directory), client: 92.47.149.211, server: servername, request: "GET /images/light.jpg HTTP/2.0", host: "servername", referrer: "https://servername/"
2021/01/21 21:41:21 [error] 13069#13069: *8 openat() "/var/www/servername/images/light.jpg" failed (2: No such file or directory), client: 92.47.149.211, server: servername, request: "GET /images/light.jpg HTTP/2.0", host: "servername", referrer: "https://servername/"
2021/01/21 21:49:53 [warn] 13069#13069: *10 an upstream response is
buffered to a temporary file /var/lib/nginx/fastcgi/3/00/0000000003 while reading upstream, client: 92.47.198.158, server: servername, request: "POST /courseclass/17 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/servername.sock:", host: "servername",
referrer: "https://servername/courseclass/17"
The problem was in the less memory of the server. After I increase it from 5GB to 10GB there is no problems. But before that there was about 200MB and I tried to upload a video of 100MB

Missing minified js file in Wordpress

I have done a fresh installation of WordPress on AWS Elastic BeanStalk.
I am not using the root directory. I have moved the WordPress code to the public directory.
I am not able to open the page to add or edit the post/page.
I am getting the below error in Nginx logs.
I tried both WordPress 5.5.3 and 5.4.4
Any clue where the issue can be?
2020/12/04 12:24:47 [warn] 13851#0: *65 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/fastcgi/8/00/0000000008 while reading upstream, client: 103.5.133.148, server: , request: "GET /wp-admin/post-new.php?post_type=page HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/upload.php"
2020/12/04 12:24:48 [error] 13851#0: *68 open() "/var/www/html/public/wp-includes/js/dist/vendor/wp-polyfill.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/wp-polyfill.min.js?ver=7.4.4 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:48 [error] 13851#0: *69 open() "/var/www/html/public/wp-includes/js/dist/vendor/lodash.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/lodash.min.js?ver=4.17.15 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:49 [error] 13851#0: *68 open() "/var/www/html/public/wp-includes/js/dist/vendor/react.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/react.min.js?ver=16.9.0 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:49 [error] 13851#0: *69 open() "/var/www/html/public/wp-includes/js/dist/vendor/react-dom.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/react-dom.min.js?ver=16.9.0 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
2020/12/04 12:24:49 [error] 13851#0: *72 open() "/var/www/html/public/wp-includes/js/dist/vendor/moment.min.js" failed (2: No such file or directory), client: 103.5.133.148, server: , request: "GET /wp-includes/js/dist/vendor/moment.min.js?ver=2.22.2 HTTP/1.1", host: "blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com", referrer: "http://blog-env.eba-gnu2jhwn.us-east-1.elasticbeanstalk.com/wp-admin/post-new.php?post_type=page"
The issue was caused by git. I am using composer with WordPress, so had added the 'vendor/' entry in the .gitignore file.
Because of this none of the vendor folders were getting shipped to the server and hence the missing files.
I changed 'vendor/' to '/vendor' in .gitignore file. Ran 'git rm -r --cached .' and committed the code again.
It works now.

How to Fix an Error PHP Fatal error: Out of memory?

I do not have a server running, error 502 within 25 minutes, I see the following in the logs:
2017/08/19 19:36:30 [error] 7652#0: *978 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 207.46.13.158, server: vamdodoma.ru, request: "GET /catalog/2-mestnye-divany/S39861885.html/ HTTP/1.1", upstream: "fastcgi://unix:/var/php-nginx/14617404421463.sock/socket:", host: "vamdodoma.ru"
2017/08/19 19:36:31 [error] 7651#0: *622 FastCGI sent in stderr: "PHP Fatal error: Out of memory (allocated 262144) (tried to allocate 8589938688 bytes) in Unknown on line 0" while reading response header from upstream, client: 46.237.19.175, server: vamdodoma.ru, request: "GET /api/app.getCities HTTP/1.1", upstream: "fastcgi://unix:/var/php-nginx/14617404421463.sock/socket:", host: "vamdodoma.ru"
2017/08/19 19:36:31 [error] 7651#0: *622 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 46.237.19.175, server: vamdodoma.ru, request: "GET /api/app.getCities HTTP/1.1", upstream: "fastcgi://unix:/var/php-nginx/14617404421463.sock/socket:", host: "vamdodoma.ru"
Server PHP, NGINX, MySQL
In php.ini memory_limit = 48000M
Why is not enough memory available?

PHP-FPM and Nginx: "Resource temporarily unavailable" errors in proxy_error_log

I found the following discussion that was posted 4 years ago: 502 Gateway Errors under High Load (nginx/php-fpm)
Where someone had a similar issue as mine, but unfortunately I believe that the configurations he received were customized for his own server specs and I can't use the same configuration on my server. Anyway I would like to present the problem I have by myself and not to just tell you to go to the link I sent and read someone else's problem.
So to my own story - I have a big social media page where I post links to my website articles, which means that I have lots of traffic spikes during the day each time I share something. Recently I noticed that the site is too slow and sometimes not loading at all and unfortunately I am not very familiar in solving issues like this and I don't have a system administrator who manages my dedicated server to contact with since I rent it from OVH which offers unmanaged servers in low cost. The server has pretty good specs and this issue happens even when there are 100 active users on site. I can also see some errors in my server logs.
Server specs are the following:
AMD Opteron(tm) Processor 4334, AMD Opteron(tm) Processor 4334 (6 core(s))
SoftRaid 3x160GB SSD
32GB RAM
1Gbps connection
CentOS x64 Linux release 7.2.1511 (Core)
Plesk v12.5.30
The errors I was talking about:
proxy_error_log
2016/10/02 09:49:36 [error] 6931#0: *469804 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416176.6522459983825683593750 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416176.6522459983825683593750"
2016/10/02 09:49:36 [error] 6931#0: *469806 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416176.8384990692138671875000 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416176.8384990692138671875000"
2016/10/02 09:49:38 [error] 6931#0: *469826 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 73.77.251.156, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:38 [error] 6931#0: *469830 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 217.123.129.73, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469840 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.1317949295043945312500 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.1317949295043945312500"
2016/10/02 09:49:39 [error] 6931#0: *469842 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2605:6001:f08a:3400:88d6:8b94:4499:8e36, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469845 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 162.158.75.61, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
2016/10/02 09:49:39 [error] 6931#0: *469847 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.6054229736328125000000 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.6054229736328125000000"
2016/10/02 09:49:39 [error] 6931#0: *469849 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2607:5300:60:5e68::, server: ###.com, request: "POST /wp-cron.php?doing_wp_cron=1475416179.6478641033172607421875 HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/wp-cron.php?doing_wp_cron=1475416179.6478641033172607421875"
2016/10/02 09:49:39 [error] 6931#0: *469851 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2601:81:4203:1bce:5809:b94c:4616:4730, server: ###.com, request: "POST /wp-admin/admin-ajax.php HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://www.###.com/###/"
2016/10/02 09:49:40 [error] 6931#0: *469853 connect() to unix:///var/www/vhosts/system/###.com/php-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 2602:306:8b97:11a0:6843:ad77:251e:864a, server: ###.com, request: "GET /###/ HTTP/1.1", upstream: "fastcgi://unix:///var/www/vhosts/system/###.com/php-fpm.sock:", host: "www.###.com", referrer: "http://m.facebook.com/"
I have tons of these ^
I will now attach some of my configuration files as the guy in the other thread I linked to did, so you will have some sort of idea on what's going on my server.
php-fpm.conf
include=/etc/php-fpm.d/*.conf
[global]
pid = /run/php-fpm/php-fpm.pid
error_log = /var/log/php-fpm/error.log
daemonize = no
/etc/php-fpm.d/www.conf
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
user = apache
group = apache
pm = dynamic
pm.max_children = 250
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 35
pm.max_requests = 500
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
/etc/php-fpm.d/###.com.conf
[###.com]
prefix = /var/www/vhosts/system/$pool
user = ###
group = psacln
listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660
chdir = /
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
catch_workers_output = yes
php_value[max_input_time] = 60
php_value[max_execution_time] = 60
php_value[memory_limit] = 128M
php_value[open_basedir] = none
sysctl.conf
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.eth0.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
net.ipv6.conf.eth0.accept_ra = 0
net.core.somaxconn = 4096
net.ipv4.tcp_fin_timeout = 20
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_syncookies = 1
/etc/nginx/nginx.conf
worker_processes 1;
include /etc/nginx/modules.conf.d/*.conf;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_tokens off;
include /etc/nginx/conf.d/*.conf;
}
# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
/etc/security/limits.conf has no configurations, only comments inside.
These are the results for the following commands:
ulimit -n
1024
ulimit -Sn
1024
ulimit -Hn
4096
cat /proc/sys/fs/file-max
3266168
free -m
total used free shared buff/cache available
Mem: 32089 1284 3784 1718 27020 28936
Swap: 1532 1 1531
About fastcgi_params - I have no idea where to find this one on Plesk. I could only find a file with variables that I don't know their values.
Like these lines for example (that's how the whole file look like):
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
I am sorry if there's something missing, I really tried to make it detailed as possible and it's also not easy to find where the configuration files are located with Plesk. I had to do some research for each file I attached above... (That's one of the reasons I don't like Plesk to be honest, but that's what I have atm)
If there are any more configuration files you need me to send, please let me know and I will attach it in the comments. Please also let me know where I can find them (considering that I'm using Plesk v12.5).
It's really important for me to configure the server properly for my needs and for my specs and get rid of the errors, so please help me. :)
Thank you!
Try to increase your php-fpm children number, for example like this:
pm.max_children = 30
pm.start_servers = 10
pm.min_spare_servers = 3
pm.max_spare_servers = 15
then sudden spikes of traffic won't generate the error
make sure you have increased php-fpm backlogs variable:
listen.backlog = 100000
also increase the number of net.core.somaxconn=2000000 (kernel parameters at runtime).
like this :
sysctl net.core.somaxconn=200000
sysctl -p

Nginx/PHP-CGI - 502 Bad Gateway

I appear to be having an issue with my website when I browse around (just clicking links here and there), and my system would return a random 502 Bad Gateway error. I can hit the refresh button and it would appear to work fine.
Error Message:
2012/08/16 11:17:54 [error] 26777#0: *1049 recv() failed
(104: Connection reset by peer) while reading response header from upstream,
client: 66.162.194.10, server: SITE,
request: "GET /wp-admin/admin-ajax.php?action=dashboard-widgets&widget=dashboard_secondary HTTP/1.1",
upstream: "fastcgi://unix:/tmp/php.socket:", host: "SITE", referrer: "SITE/wp-admin/index.php"
2012/08/16 11:17:54 [error] 26777#0: *1049 connect() failed
(111: Connection refused) while connecting to upstream,
client: 66.162.194.10, server: SITE,
request: "GET /wp-admin/admin-ajax.php?action=dashboard-widgets&widget=dashboard_secondary HTTP/1.1",
upstream: "http://127.0.0.1:9000/wp-admin/admin-ajax.php?action=dashboard-widgets&widget=dashboard_secondary",
host: "SITE", referrer: "http://SITE/wp-admin/index.php"
/etc/nginx/nginx.conf:
user www-data;
worker_processes 8;

Categories