fixing 504 gateway timeout issue nginx unable to load site - nginx

I had executed a select query and suddenly after that it start showing gateway timeout 504 error
root#dtest:/etc# service php-fcgi start
its has nginx and php-fcgi
[....] Starting spawn-fcgi:spawn-fcgi: bind failed: Address already in use
failed!

Related

GCP deployment with nginx - uwsgi - flask fails

I have a very simple flask app that is deployed on GKE and exposed via google external load balancer. And getting random 502 responses from the backend-service (added a custom headers on backend-service and nginx to make sure the source and I can see the backend-service's header but not nginx's)
The setup is;
LB -> backend-service -> neg -> pod (nginx -> uwsgi) where pod is the application built using flask and deployed via uwsgi and nginx.
The scenario is to handle image uploads in simple-secured way. Sender sends me a token with upload request.
My flask app
receive request and check the sent token via another service using "requests".
If token valid, proceed to handle the image and return 200
If token is not valid, stop and send back a 401 response.
First, I got suspicious about the 200 and 401's. And reverted all responses to 200. Following some of the expected responses, server starts to respond 502 and keep sending it. "Some of the messages at the very beginning succeeded".
nginx error logs contains below lines
2023/02/08 18:22:29 [error] 10#10: *145 readv() failed (104: Connection reset by peer) while reading upstream, client: 35.191.17.139, server: _, request: "POST /api/v1/imageUpload/image HTTP/1.1", upstream: "uwsgi://127.0.0.1:21270", host: "example-host.com"
my uwsgi.ini file is as below;
[uwsgi]
socket = 127.0.0.1:21270
master
processes = 8
threads = 1
buffer-size = 32768
stats = 127.0.0.1:21290
log-maxsize = 104857600
logdate
log-reopen
log-x-forwarded-for
uid = image_processor
gid = image_processor
need-app
chdir = /server/
wsgi-file = image_processor_application.py
callable = app
py-auto-reload = 1
pidfile = /tmp/uwsgi-imgproc-py.pid
my nginx.conf is as below
location ~ ^/api/ {
client_max_body_size 15M;
include uwsgi_params;
uwsgi_pass 127.0.0.1:21270;
}
Lastly, my app has a healthcheck method with simple JSON response. It does no extra stuff and simply returns. This never fails as explained above.
Edit : my nginx access logs in the pod shows the response as 401 while the client receives 502.
for those who gonna face with the same issue, the problem was post data reading (or not reading).
nginx was expecting to get post data read by the proxied, in our case uwsgi, app. But according to my logic I was not reading it in some cases and returning back the response.
Setting uwsgi post-buffering solved the issue.
post-buffering = %(16 * 1024 * 1024)
Which led me to this solution;
https://stackoverflow.com/a/26765936/631965
Nginx uwsgi (104: Connection reset by peer) while reading response header from upstream

Nuxtjs failed: Error during WebSocket handshake: Unexpected response code: 500

I setup my nuxt on centOs 7 and I use nginx as server when I run npm run dev on server and open chrome it show me in console this:
WebSocket connection to 'wss://www.mydomain.com/_loading/ws' failed: Error during WebSocket handshake: Unexpected response code: 500
and try to reconnect again then same error show,
what is the problem?
is it caused by nginx or nuxtjs ?
I detected the issue,
It was caused by centOs server it needs to upgrade its kernel
I do upgrade the centOs and upgrade its kernel and every thing seems Okay

nginx not running that displays 404 message

I've been following the directions based on http://linoxide.com/linux-how-to/install-configure-femp-stack/
So far when I ran my ip address http://ip address
I got an error that says "404 not found."
I've already enable sysrc nginx_enable=yes and that one works
Next I tried nginx -t and that part works and it says:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Then I tried nginx result and it it didn't work and I got the message saying "invalid option: "result"" it didn't work then I tried service nginx start and
it start running and when I type my ip address I kept getting 404 message.

Kibana - socket hang up error

I am running Kibana behind IIS reverse proxy server and getting following error
Courier Fetch Error: unhandled courier request error: socket hang up
I am on Version: 4.2.2, Build: 9177.
I get this error only when I use proxy server which I need to restrict access to Kibana. I am not sure what is causing this or how to fix it.
Error: unhandled courier request error: socket hang up
at handleError (http://kibana-server/bundles/kibana.bundle.js:70047:23)
at DocRequest.AbstractReqProvider.AbstractReq.handleFailure (http://kibana-server/bundles/kibana.bundle.js:69967:15)
at http://kibana-server/bundles/kibana.bundle.js:69861:18
at Array.forEach (native)
at http://kibana-server/bundles/kibana.bundle.js:69859:19
at wrappedErrback (http://kibana-server/bundles/commons.bundle.js:39286:79)
at http://kibana-server/bundles/commons.bundle.js:39419:77
at Scope.$eval (http://kibana-server/bundles/commons.bundle.js:40406:29)
at Scope.$digest (http://kibana-server/bundles/commons.bundle.js:40218:32)
at Scope.$apply (http://kibana-server/bundles/commons.bundle.js:40510:25)
If you have enabled Integrated Windows Authentication in your IIS the Kibana server cannot process the request, because the http-Authorization-Header is too large (group memberships are stored in the PAC field of the kerberos tickets).
We had the same Problem with an Apache reverse proxy server in front of Kibana. The solution is to unset the Authorization-Header after Kerberos/NTLM-Authentication is done and before sending the proxy request to Kibana.
Configuration for Apache:
RequestHeader unset Authorization
Try removing http.cors and http.compression as noted in https://github.com/elastic/kibana/issues/6719

Nginx returns 502 error when php-fpm returns 500

I'm running nginx with php-fpm. Whenever my Symfony app crashes, it returns a 500 error with the debug info and stack traces I need. The problem is Nginx dumps that info and returns a 502 error with no content.
How can I configure nginx to forward along the 500 error and content from php-fpm?
You can use "proxy_intercept_errors on" to transfer error code to client.
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors
If your Symfony app crashes before any content was returned, then there is no content.

Resources