dockerfile - docker中,nginx配置重写循环错误

查看:270
本文介绍了dockerfile - docker中,nginx配置重写循环错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

日志如下:

2017/05/23 11:44:06 [error] 5#5: *39 rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/admin.php/public/login.html", client: 192.168.99.1, server: , request: "GET /admin.php/public/login.html HTTP/1.1", host: "192.168.99.100:81", referrer: "http://192.168.99.100:81/admin.php"
2017/05/23 11:44:06 [error] 5#5: *40 rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/admin.php/public/login.html", client: 192.168.99.1, server: , request: "GET /admin.php/public/login.html HTTP/1.1", host: "192.168.99.100:81", referrer: "http://192.168.99.100:81/admin.php"
2017/05/23 11:45:05 [error] 5#5: *42 rewrite or internal redirection cycle while processing "/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/admin.php/public/login.html", client: 192.168.99.1, server: , request: "GET /admin.php/public/login.html HTTP/1.1", host: "192.168.99.100:81", referrer: "http://192.168.99.100:81/admin.php"

nginx配置文件如下:

#upstream php {
#        server php-fpm:9000;
#}

server {

        listen 80 default;
        root /var/www/html/webroot/Public;
        index index.php index.html;
        location / {
               index  index.html index.htm index.php l.php;
               #autoindex  on;
               if (!-e $request_filename) {
               #重写路由,去掉前缀
                  rewrite ^/(.*)$ /index.php/$1 last;
                  break;
               }
        }


        location ~ \.php$ {
            fastcgi_pass php-fpm:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
        }
}

这个配置文件在我之前没有使用docker构建的时候,线上环境跑起来完全没问题的。

新编排目录如下:

解决方案

粗心大意

最后还是自己解决了问题,匹配路由的问题,比如说我访问/index.php/....之前那个就有问题。

  location ~ \.php(.*)$ {
            fastcgi_pass php-fpm:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

            include        fastcgi_params;
        }

这篇关于dockerfile - docker中,nginx配置重写循环错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆