Tag Archives: nginx

502 Gateway Errors under High Load (nginx/php-fpm)

Questions: I work for a rather busy internet site that is often gets very large spikes of traffic. During these spikes hundreds of pages per second are requested and this produces random 502 gateway errors. Now we run Nginx (1.0.10) and PHP-FPM on a machine with 4x SAS 15k drives (raid10) with a 16 core… Read More »

How to correctly link php-fpm and Nginx Docker containers?

Questions: I am trying to link 2 separate containers: nginx:latest php:fpm The problem is that php scripts do not work. Perhaps the php-fpm configuration is incorrect. Here is the source code, which is in my repository. Here is the file docker-compose.yml: nginx: build: . ports: – “80:80” – “443:443” volumes: – ./:/var/www/test/ links: – fpm… Read More »

nginx clean url with seo friendly file names

Questions: I wish to implement the following which is working perfectly under Apache. This is being done for better SEO of the URLs. Example URLS: http://www.astrogyan.com/enter/indian_astrology_horoscope_chart_prediction.html http://www.astrogyan.com/know_your_gemstone/gID-7/sani_planet_saturn_gemstone_blue_sapphire_neelam.html What I am exactly looking forward to is a location regex to catch all extension-less php scripts in the ROOT FOLDER ONLY for processing by php-fptm. In all… Read More »

Nginx – Customizing 404 page

Questions: Nginx+PHP (on fastCGI) works great for me. When I enter a path to a PHP file which doesn’t exist, instead of getting the default 404 error page (which comes for any invalid .html file), I simply get a “No input file specified.”. How can I customize this 404 error page? Answers: You use the… Read More »

nginx 502 bad gateway

Questions: I get a 502 Bad Gateway with nginx when using spawn fcgi to spawn php5-cgi. I use this to span an instance on server start using the following line in rc.local /usr/bin/spawn-fcgi -a -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid presumably I’m getting the error because the spawn-fcgi / php5-cgi… Read More »

PHP Flush that works… even in Nginx

Questions: Is it possible to echo each time the loop is executed? For example: foreach(range(1,9) as $n){ echo $n.”\n”; sleep(1); } Instead of printing everything when the loop is finished, I’d like to see it printing each result per time. Answers: FINAL SOLUTION So that’s what I found out: Flush would not work under Apache’s… Read More »

nginx redirect loop, remove index.php from url

Questions: I want any requests like http://example.com/whatever/index.php, to do a 301 redirect to http://example.com/whatever/. I tried adding: rewrite ^(.*/)index.php$ $1 permanent; location / { index index.php; } The problem here, this rewrite gets run on the root url, which causes a infinite redirect loop. Edit: I need a general solution http://example.com/ should serve the file… Read More »