使用反向代理进行过多重定向

2024-05-07

Setup:

  • 云flare DNS
  • docker 撰写
  • nginx 反向代理
  • WordPress 的 fpm
  • Nginx PHP 处理程序

Problem

重定向太多,如以下日志所示:

Attaching to wp_db, wp, wp_web
wp_db     | 2020-01-27 12:13:10+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.11+maria~bionic started.
wp_db     | 2020-01-27 12:13:10+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
wp_db     | 2020-01-27 12:13:10+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.11+maria~bionic started.
wp        | [27-Jan-2020 12:13:10 UTC] PHP Warning:  mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22
wp        | 
wp        | MySQL Connection Error: (2002) Connection refused
wp_db     | 2020-01-27 12:13:11 0 [Note] mysqld (mysqld 10.4.11-MariaDB-1:10.4.11+maria~bionic-log) starting as process 1 ...
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Using Linux native AIO
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Uses event mutexes
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Number of pools: 1
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Using SSE2 crc32 instructions
wp_db     | 2020-01-27 12:13:11 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Completed initialization of buffer pool
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Creating shared tablespace for temporary tables
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: 10.4.11 started; log sequence number 20529037; transaction id 14604
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
wp_db     | 2020-01-27 12:13:11 0 [Note] Plugin 'FEEDBACK' is disabled.
wp_db     | 2020-01-27 12:13:11 0 [Note] Server socket created on IP: '::'.
wp_db     | 2020-01-27 12:13:11 0 [Note] InnoDB: Buffer pool(s) load completed at 200127 12:13:11
wp_db     | 2020-01-27 12:13:11 0 [Warning] 'proxies_priv' entry '@% root@8da7502dc057' ignored in --skip-name-resolve mode.
wp_db     | 2020-01-27 12:13:11 0 [Note] Reading of all Master_info entries succeeded
wp_db     | 2020-01-27 12:13:11 0 [Note] Added new Master_info '' to hash table
wp_db     | 2020-01-27 12:13:11 0 [Note] mysqld: ready for connections.
wp_db     | Version: '10.4.11-MariaDB-1:10.4.11+maria~bionic-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
wp        | [27-Jan-2020 12:13:13] NOTICE: fpm is running, pid 1
wp        | [27-Jan-2020 12:13:13] NOTICE: ready to handle connections
wp        | 192.168.48.4 -  27/Jan/2020:12:13:56 +0000 "GET /index.php/wp-admin/install.php"     302
wp_web    | 172.28.0.4 - - [27/Jan/2020:12:13:56 +0000] "GET /index.php/wp-admin/install.php HTTP/1.1" 302 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0" "MYSERVERIP, 162.158.90.139"
wp        | 192.168.48.4 -  27/Jan/2020:12:13:56 +0000 "GET /index.php/wp-admin/install.php" 302
wp_web    | 172.28.0.4 - - [27/Jan/2020:12:13:56 +0000] "GET /index.php/wp-admin/install.php HTTP/1.1" 302 5 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0" "MYSERVERIP, 162.158.90.139"
// here is the loop

Configs:

docker-compose.yml

version: '3'

services:
  wp_db:
    image: mariadb
    container_name: wp_db
    command: --transaction-isolation=READ-COMMITTED --log-bin=mysqld-bin --binlog-format=ROW
    restart: always
    volumes:
      - ./wp_db:/var/lib/mysql
    environment:
      - PUID=33
      - PGID=33
      - MYSQL_PASSWORD=wordpress # needs to be hardcoded
      - MYSQL_DATABASE=wordpress # needs to be hardcoded
      - MYSQL_USER=wordpress # needs to be hardcoded
      - MYSQL_ROOT_PASSWORD=***
    networks:
      - wordpress

  wp:
    image: wordpress:php7.4-fpm-alpine
    container_name: wp
    depends_on:
      - wp_db
    restart: always
    environment:
      - PUID=33
      - PGID=33
      - WORDPRESS_DB_USER=${MYSQL_WORDPRESS_USER}
      - WORDPRESS_DB_PASSWORD=${MYSQL_WORDPRESS_PASSWORD}
      - WORDPRESS_DB_NAME=${MYSQL_WORDPRESS_DB}
      - WORDPRESS_DB_HOST=wp_db
    volumes:
      - ./wordpress-la:/var/www/html:rw
    networks:
      - wordpress

  wp_web:
    build: ./wp_web
    container_name: wp_web
    restart: always
    volumes:
      - ./wordpress-la:/var/www/html
      - ./wp_web/nginx.conf:/etc/nginx/nginx.conf
    environment:
      - PUID=33
      - PGID=33
      - VIRTUAL_HOST=domain.com
      - LETSENCRYPT_HOST=domain.com
    depends_on:
      - wp
    networks:
      - wordpress
      - proxy-tier

networks:
  proxy-tier:

  wordpress:

nginx.conf for wp_web

worker_processes auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  65;
    real_ip_header    X-Real-IP;

    upstream php {
        server wp:9000;
    }

    server {
        server_name domain.com;

        root /var/www/html;
        index index.php;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass php;
        proxy_redirect off;
        }

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

nginx 反向代理会自动创建其配置,并将请求转发到wp_web (IIRC).

Problem:

如何修复重定向循环?其他一切似乎都有效。我还运行其他容器并通过以下方式访问domain2.com没有任何问题。

提前致谢 ;)


就像@Damocles所说,必须有

$_SERVER['HTTPS'] = 'on'; in wp-config.php。标准配置

 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
     $_SERVER['HTTPS'] = 'on';
 }

似乎还不够。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用反向代理进行过多重定向 的相关文章

随机推荐

  • Bash:查找并连接文件

    我有以下结构 home DIR1 file ab csv DIR2 file cd csv DIR3 file3 ef csv Where file csv包含多行浮点数 每个 DIR 都有不同的浮点数 我想抓取所有的内容file csv文
  • C++11 的 LLVM&Clang 支持

    我有一些为 MS VC 10 编写的代码 我使用 C 11 特别是像这样的表达式 std function
  • Firebase 3.x - Facebook 登录

    InFirebase 2 5 1 我曾经这样做过 而且很有效 IBAction func facebookLoginDidTouch sender AnyObject let facebookLogin FBSDKLoginManager
  • 使用 setcap 功能运行时 JLI_InitArgProcessing 的 Java“符号查找错误”

    我们在服务器上安装了 Java 11 旨在监视网络接口的流量 初始安装后 yum install java 11 openjdk devel x86 64 the java命令对两者都适用root and a 普通用户 但是 我们的 Jav
  • 将画布输出图像调整为特定尺寸(宽度/高度)

    我有一个大画布 5000x5000 我想拍一张照片并在客户端创建一个缩略图 我可以使用捕获图像canvas toDataURL但我该如何调整它的大小 我必须创建一个新的吗
  • 什么是“标量”查询?

    我正在使用 LLBLGEN 其中有一种方法可以将查询作为scalar query 谷歌搜索给了我一个定义scalar sub query 它们一样吗 标量查询是返回由一列组成的一行的查询
  • 当互联网连接丢失时,不间断地读取输入流

    我使用异步任务来下载文件 它正常工作 直到我关闭我的 Android 的 wifi 连接 没有其他互联网连接 下载对话框仍然存在并且没有任何变化 当我检查日志时 我发现输入流的函数 read 不停顿 那么如何检查这个案例呢 这是我的代码 U
  • iPhone UIDatePicker 风格

    有什么方法 技巧可以更改 uiDatePicker 的大小 字体 背景颜色等吗 甚至背景颜色属性也不起作用 并且选择器的默认样式与我的应用程序的设计无关 也许你可以使用 UIPickerView 来代替 我见过人们使用图像作为背景 不过 您
  • 通过 Emacs 评估 ghci 或 Hugs 中的缓冲区

    在 Emacs 中使用 sml mode 我已经能够使用以下命令将缓冲区内容直接发送到较差的 SML 进程C c C b 现在我只想用 Haskell 做同样的事情 Haskell 模式似乎不支持这一点 所以我想知道 使用 Emacs 和
  • 如何删除/统计 s3 存储桶中的对象?

    所以我知道这是一个常见问题 但似乎没有任何好的答案 我有一个桶 里面有大量 我不知道有多少 文件 都在2k一个以内 1 我如何知道我有多少个这些文件没有列出他们 我使用过 s3cmd rb aws s3 和 jets3t 的东西 我能找到的
  • 使用“对多”关系从 NSFetchedResultsController 派生 UITableView 部分

    我的核心数据模型如下所示 article lt gt gt category 是否可以远程使用NSFetchedResultsController生成一个看起来像这样的 UITableView Category 1 Article A Ar
  • 就MVC模式而言,Struts 2中使用的Action是什么?

    在Struts2中 控制器将请求分派给Action Action将其传递给后端逻辑 这可以看作是一个非常大的过程 model 处理请求 JSP代表视图 Struts2中如何定义Action 肯定是not一个看法 是控制器还是模型 Strut
  • Postgres 重叠数组中的一列

    我有一个表 A 其中有一列 col1 其中每个记录都是整数数组 col1 1 2 3 4 1 2 6 7 1 2 3 8 9 我喜欢有一行作为结果 其中包含 col1 中所有数组的重叠或相交 select overlap col1 from
  • jQuery - 解析 JSON 数据 - 变量名称遇到问题

    我第一次深入研究 JSON 数据的使用 不过我有一些使用 jQuery 的经验 我发布到此 URL tumblr api jyoseph com api read json 我想做的是输出返回的 json 到目前为止我所拥有的 docume
  • 在 C/C++ 中使用单个初始化来初始化具有相同值的多个指针

    我想在 C C 中使用单个赋值运算符声明两个或多个具有相同值的指针 以下代码是一个示例 List a NULL List b NULL List c NULL 一行中是否有等效项 编辑 为了澄清 我正在寻找两种语言的答案 我使用 斜杠 来区
  • 如何获取与文件类型关联的图标路径和索引?

    给定一个文件类型 例如 txt 我怎样才能得到 path index 文件类型的关联图标路径和索引 例如 我想转换 txt into Path SystemRoot system32 imageres dll Index 102 有了这些信
  • Azure Media Player 在重新访问视图时无法在 Angular JS 中播放视频

    我已经在我的 angularjs 应用程序中使用了 azure 媒体播放器并且能够观看视频 但是 当重新访问视频标签所在的同一视图时 不会播放视频 而是在后台播放音频 我正在使用 ui router 进行路由 预先感谢您的快速帮助 这是我的
  • R randomForest - 如何使用“getTree”树进行预测

    背景 我可以在 R 中创建一个随机森林 set seed 1 library randomForest data iris model rf lt randomForest Species data iris importance TRUE
  • 生产中 ASP.NET Core 应用程序的实例化

    ASP NET Core 开始执行Main方法在于Program class inside Program cs文件 这会构建一个网络托管环境并告诉该网络主机开始运行 那么 有startup cs file 开发 NET Core Web
  • 使用反向代理进行过多重定向

    Setup 云flare DNS docker 撰写 nginx 反向代理 WordPress 的 fpm Nginx PHP 处理程序 Problem 重定向太多 如以下日志所示 Attaching to wp db wp wp web