WordPress的两个实例随机产生状态为301

时间:2018-10-25 22:28:50

标签: wordpress docker docker-swarm

我在docker swarm上有完全相同的包含WordPress应用程序的容器。它们都在同一网络上。 问题是在安装WordPress之后,当我将GET随机发送到第一个应用curl -I $IP1时,我收到响应301,其中包含指向IP2的链接...

第一个问题是-一个实例如何知道另一个实例?如何调试这种重定向的原因是什么? 主要问题是-如何修复它。

wordpress.yml

version: '3.5'

services:
  db:
    image: mysql:5.7
    networks:
      - proxynet
    volumes:
      - db-data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: changeme
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wp
      MYSQL_PASSWORD: changemetoo
    deploy:
      placement:
        constraints:
          - node.role == manager

  word:
    depends_on:
      - db
    image: wordpress
    networks:
      - proxynet
    volumes:
      - wp-content:/var/www/html
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wp
      WORDPRESS_DB_PASSWORD: changemetoo


volumes:
  db-data:
  wp-content:

network.yml:

networks:
  proxynet:
    name: proxynet

wordpress日志的一部分:

10.0.0.4 - - [25/Oct/2018:14:49:54 +0000] "HEAD / HTTP/1.1" 301 209 "-" "curl/7.35.0"
10.0.0.4 - - [25/Oct/2018:14:49:56 +0000] "HEAD / HTTP/1.1" 301 209 "-" "curl/7.35.0"
10.0.0.4 - - [25/Oct/2018:14:49:58 +0000] "HEAD / HTTP/1.1" 301 209 "-" "curl/7.35.0"
10.0.0.4 - - [25/Oct/2018:14:50:00 +0000] "HEAD / HTTP/1.1" 200 221 "-" "curl/7.35.0"
10.0.0.4 - - [25/Oct/2018:14:50:02 +0000] "HEAD / HTTP/1.1" 301 209 "-" "curl/7.35.0"
10.0.0.4 - - [25/Oct/2018:14:50:04 +0000] "HEAD / HTTP/1.1" 301 209 "-" "curl/7.35.0"

1 个答案:

答案 0 :(得分:0)

我认为docker中存在一个错误,我在那里创建了问题。 但事实并非如此。 如果有人会遇到与此类似的问题,则在github上有splendid answer from @thaJeztah