Yii Framework Forum: Chttpexception With Nginx - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chttpexception With Nginx Rate Topic: -----

#1 User is offline   xarope 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 26-September 13

Posted 26 September 2013 - 03:09 AM

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.
0

#2 User is offline   nineinchnick 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 622
  • Joined: 12-September 11
  • Location:Bialystok, Poland

Posted 26 September 2013 - 09:56 AM

Can you post your nginx vhost configuration?
Don't be a dick.
0

#3 User is offline   amnah 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 105
  • Joined: 23-February 13

Posted 29 September 2013 - 01:17 AM

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.
0

#4 User is offline   xarope 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 26-September 13

Posted 29 September 2013 - 09:34 PM

View Postnineinchnick, on 26 September 2013 - 09:56 AM, said:

Can you post your nginx vhost configuration?

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)
0

#5 User is offline   xarope 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 26-September 13

Posted 29 September 2013 - 10:37 PM

View Postamnah, on 29 September 2013 - 01:17 AM, said:

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.

Thanks, I assume you are referring to this: http://stackoverflow...inx-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.
0

#6 User is offline   xarope 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 26-September 13

Posted 10 October 2013 - 09:54 PM

nobody else has seen this issue with nginx not handling the chttpexception errors thrown in Yii, properly?
0

#7 User is offline   MattD 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 06-February 12

Posted 24 January 2014 - 05:44 PM

Same thing for me. Have you been able to fix it?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users