Tag Archives: nginx

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 127.0.0.1 -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 »

Docker-compose and nginx proxy

Questions: I am trying to use jwilder/nginx-proxy as a reverse proxy for my angular2 app that is broken down into 3 containers (angular, express and database). I have tried different configurations to proxy requests to my app on port 80, however when I try to run docker-compose I get : ERROR: for angular Cannot start… Read More »

Apache rewrite rule to Nginx

Questions: I’m looking to rewrite htaccess rules into nginx rules Here is my htaccess that need to be converted: RewriteEngine On RewriteRule ^/?c/([^/]+)/?$ search_result.php?category_id=$1 [L,QSA] RewriteRule ^d/([^/.]+)/?$ detail.php [NC,L] I tried this site, then insert into my vhost domain.conf: location / { rewrite ^/?c/([^/]+)/?$ /search_result.php?category_id=$1 break; } location /d { rewrite ^/d/([^/.]+)/?$ /detail.php break; }… Read More »