xarope
(Y Ong)
1
I have yii working with nginx, following the instructions in www.yiiframework.com/doc/guide/1.1/en/quickstart.apache-nginx-config
(it’s almost exactly what is in there, barring of course the change in the root parameter since I’m using /var/www/yiiapp/htdocs)
however, when I raise an exception using e.g.
throw new CHttpException(406, print_r("Error found", true));
I get a 502 bad gateway error on the nginx side.
Looking in /var/log/nginx/error.log, I see this sort of error:
2013/09/26 15:59:47 [error] 6906#0: *104 upstream sent invalid status "CHttpException" while reading response header from upstream, client: 10.25.3.231, server: , request: "GET /index.php?r=modulename/update&id=3009 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "10.0.0.42", referrer: "http: //10.0.0.42/index.php?r=modulename/index"
I can’t find any references at all, when I google for ChttpException and nginx, so I must be doing something very wrong here?
NB: I can’t post embedded links, so that http:<space>//10.0.0.42… <space> is not supposed to be there, in case anybody thinks my URL is incorrect.
Can you post your nginx vhost configuration?
amnah
(Jellysandwich5+1)
3
I ran into a 502 error issue a while back, may be related to yours.
Can’t post links, but search google for “upstream too big nginx codeigniter”. First result on stackoverflow.
xarope
(Y Ong)
4
sure, here it is:
server {
set $host_path "/var/www/yiiapp";
server_name mysite;
root $host_path/htdocs;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
# prevent nginx from serving dotfiles (.htaccess, .svn, .git, etc.)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
very mildly sanitised (i.e. server_name)
xarope
(Y Ong)
5
Thanks, I assume you are referring to this: http://stackoverflow.com/questions/13894386/upstream-too-big-nginx-codeigniter
I tried both the proxy* parameters in nginx.conf and the fastcgi* parameters in the ~.php$ location in my server config, unfortunately still no go.
And for completeness, this is a test server, with only this one site running for now, I even turned off gzip in case it was a factor.
xarope
(Y Ong)
6
nobody else has seen this issue with nginx not handling the chttpexception errors thrown in Yii, properly?
MattD
(Dalmau)
7
Same thing for me. Have you been able to fix it?