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

发布于 2022-09-04 23:34:38 字数 2487 浏览 17 评论 0

日志如下:

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构建的时候,线上环境跑起来完全没问题的。

新编排目录如下:

clipboard.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最单纯的乌龟 2022-09-11 23:34:38

粗心大意

最后还是自己解决了问题,匹配路由的问题,比如说我访问/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;
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文