502 Bad Gateway - Phalcon + Nginx + CentOS7

Hi. I have a digitalocean server running phalcon. But I am not trying to fix my URLs so they are pretty. I had everything working on the default config for Nginx, although I had to go to domain/app/public without rewrites, you know... the "unpretty way."

In an attempt to clean up the urls, so I could go domain.me, i checked out these "installation notes" (https://docs.phalconphp.com/en/latest/reference/nginx.html)

I tried all of the configurations (adjusted for my domain, of course), and came up with errors ranging from a simple text "Access denied" to now "502 Bad Gateway" error.

I am not sure what the problem is, I have checked out other similar threads, and they offer little in the way of relevant guidance that I haven't already tried. I want to clarify that everything is installed and working, prior to my adjusting the nginx config.

Here is my current config:

> server { > listen 80; > servername localhost; > > charset utf-8; > > #accesslog /var/log/nginx/host.access.log main; > > set $rootpath '/usr/share/nginx/html/liamhockley-www/hockley%5Fpersonal/public'; > > location / { > root $rootpath; > index index.php index.html index.htm; > > # if file exists return it right away > if (-f $requestfilename) { > break; > } > > # otherwise rewrite it > if (!-e $requestfilename) { > rewrite ^(.+)$ /index.php?url=$1 last; > break; > } > } > > location ~ .php { > # tryfiles $uri =404; > > fastcgiindex /index.php; > fastcgipass; > > include fastcgiparams; > fastcgisplitpathinfo ^(.+.php)(/.+)$; > fastcgiparam PATHINFO $fastcgipathinfo; > fastcgiparam PATHTRANSLATED $documentroot$fastcgipathinfo; > fastcgiparam SCRIPTFILENAME $documentroot$fastcgiscriptname; > } > > location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { > root $root_path; > } > }

>Start at the log files... http://serverfault.com/questions/433024/how-can-i-debug-nginx-further-than-the-error-log

Ok. Thanks for the response. The log file is showing the following:

>2015/08/17 12:39:20 [error] 10214#0: *5 connect() failed (111: Connection refused) while connecting to upstream, client: >XX.XX.XXX.XX, server: XXX.me, request: "GET / HTTP/1.1", upstream: "fastcgi://", host: "XXX.me"

Note: I replaced the ip/domain with XXX.

It appears to be telling me there is a problem with "fastcgi" ? Where would I continue my troubleshooting? Thanks.

Nevermind. I am just going to rebuild my web server from scratch, and look for a more traditional (file based) PHP framework. I don't think this is worth the hassle. Thanks for your help.

The configuration of the nginx when we are new users is a little tricky, but once we got is worth the performance.

Try changing the listen to 8080 and restart nginx


I actually figured that my issue was very likely that I was listening on a unix socket instead of "". I already moved on and decided to use Laravel-Lumen microframework, especially considering this isn't a performance critical application I am working on.

I will certainly look in to this Framework again sometime. Until then, thank you for your help.