yii2高级模板:登录会导致inifinite重定向循环


yii2 advanced template: logging in causes inifinite redirect loop

我已经完成并上传了我的yii2项目(高级模板)到主机(在nginx 1.4.4上运行)。现在,当我想登录到管理后端并输入登录名/密码时,它会启动一个无限重定向循环。在我的本地服务器中,它并没有这样的行为。

我上网冲浪,但找不到任何答案。希望有人面对过这样的情况,能够弄清楚问题出在哪里。

一些细节:

服务器:nginx 1.4.4;X-可缓存:是Varnish也处于启用状态。

如有必要,我可以提供更多信息。

您应该将应用程序分为两部分。将前端会话和后端会话分开。阅读本指南。推荐的Nginx配置http://www.yiiframework.com/doc-2.0/guide-start-installation.html

server {
    charset utf-8;
    client_max_body_size 128M;
    listen 80; ## listen for ipv4
    #listen [::]:80 default_server ipv6only=on; ## listen for ipv6
    server_name mysite.local;
    root        /path/to/basic/web;
    index       index.php;
    access_log  /path/to/basic/log/access.log;
    error_log   /path/to/basic/log/error.log;
    location / {
        # Redirect everything that isn't a real file to index.php
        try_files $uri $uri/ /index.php?$args;
    }
    # uncomment to avoid processing of calls to non-existing static files by Yii
    #location ~ '.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    #    try_files $uri =404;
    #}
    #error_page 404 /404.html;
    location ~ '.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        fastcgi_pass   127.0.0.1:9000;
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        try_files $uri =404;
    }
    location ~ /'.(ht|svn|git) {
        deny all;
    }
}