gpt4 book ai didi

wordpress - 反向代理的重定向太多

转载 作者:行者123 更新时间:2023-12-05 08:20:11 29 4
gpt4 key购买 nike

设置:

  • cloudflare DNS
  • docker-compose
  • nginx 反向代理
  • wordpress
  • nginx php 处理程序

问题

太多的重定向,就像在这些日志中:

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

配置:

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 用于 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)。

问题:

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

提前致谢;)

最佳答案

就像@Damocles 所说的那样,必须有

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

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

好像还不够。

关于wordpress - 反向代理的重定向太多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59931256/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com