Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nginx通过ecs反向代理到docker容器中的wordpress_Wordpress_Docker_Nginx_Amazon Ecs_Nginx Reverse Proxy - Fatal编程技术网

Nginx通过ecs反向代理到docker容器中的wordpress

Nginx通过ecs反向代理到docker容器中的wordpress,wordpress,docker,nginx,amazon-ecs,nginx-reverse-proxy,Wordpress,Docker,Nginx,Amazon Ecs,Nginx Reverse Proxy,我正试图通过一个Amazon ecs实例代理传递到一个http Wordpress站点,该站点设置在docker容器中。客户端通过我们设置的测试服务器()到达站点。当用户转到时,我希望它显示在地址栏中,但调出我的Wordpress站点的页面(在端口80上) 我可以把它放到我的Wordpress网站上,但它看起来很有趣。我得到了很多混合内容错误,因为我试图通过https请求访问http文件。我知道发生了什么,但我似乎无法修复它,即使在尝试了所有我可以在网上找到的建议之后 我已经尝试更改了sites

我正试图通过一个Amazon ecs实例代理传递到一个http Wordpress站点,该站点设置在docker容器中。客户端通过我们设置的测试服务器()到达站点。当用户转到时,我希望它显示在地址栏中,但调出我的Wordpress站点的页面(在端口80上)

我可以把它放到我的Wordpress网站上,但它看起来很有趣。我得到了很多混合内容错误,因为我试图通过https请求访问http文件。我知道发生了什么,但我似乎无法修复它,即使在尝试了所有我可以在网上找到的建议之后

我已经尝试更改了sites available文件夹中Nginx文件中的几个设置,以及在Wordpress站点上更改wp-config.php中的设置。下面是我试过的一件事。我找到的几乎所有教程,以及我尝试过的所有东西,都是这本书的变体

#Nginx file

server {
    listen 443;

    location / {
        proxy_pass http://xx.xxx.xxx.xxx:80;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

我想发生的是,当用户进入地址栏时,我的Wordpress站点加载了正确的主题和我的所有图片,但仍然显示在地址栏中。

我想让您在ECS中使用HA代理反向代理。 我尝试了nginx反向代理,但失败了。以及HA代理的成功。 它比nginx配置更简单

首先,使用Docker的“链接”选项并设置“环境变量”(例如链接应用程序、链接端口)

其次,将此“环境变量”填入haproxy.cfg

另外,我建议您使用ALB的“动态端口映射”。它使工作更加灵活

taskdef.json:

# taskdef.json

{
    "executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/<APP_NAME>_ecsTaskExecutionRole",
    "containerDefinitions": [
      {
        "name": "<APP_NAME>-rp",
        "image": "gnokoheat/ecs-reverse-proxy:latest",
        "essential": true,
        "memoryReservation": <MEMORY_RESV>,
        "portMappings": [
          {
            "hostPort": 0,
            "containerPort": 80,
            "protocol": "tcp"
          }
        ],
        "links": [
          "<APP_NAME>"
        ],
        "environment": [
          {
            "name": "LINK_PORT",
            "value": "<SERVICE_PORT>"
          },
          {
            "name": "LINK_APP",
            "value": "<APP_NAME>"
          }
        ]
      },
      {
        "name": "<APP_NAME>",
        "image": "<IMAGE_NAME>",
        "essential": true,
        "memoryReservation": <MEMORY_RESV>,
        "portMappings": [
          {
            "protocol": "tcp",
            "containerPort": <SERVICE_PORT>
          }
        ],
        "environment": [
          {
            "name": "PORT",
            "value": "<SERVICE_PORT>"
          },
          {
            "name": "APP_NAME",
            "value": "<APP_NAME>"
          }
        ]
      }
    ],
    "requiresCompatibilities": [
      "EC2"
    ],
    "networkMode": "bridge",
    "family": "<APP_NAME>"
  }
Dockerfile(haproxy):

见:

Github:

Docker镜像:gnokoheat/ecs反向代理:最新


WP\u HOME
WP\u SITEURL
应设置为
https://test.xxxxxxx.com
我尝试了这个,但当我转到该页面时,它显示test.xxxxxxx.com当前无法处理此请求。HTTP错误500
# taskdef.json

{
    "executionRoleArn": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/<APP_NAME>_ecsTaskExecutionRole",
    "containerDefinitions": [
      {
        "name": "<APP_NAME>-rp",
        "image": "gnokoheat/ecs-reverse-proxy:latest",
        "essential": true,
        "memoryReservation": <MEMORY_RESV>,
        "portMappings": [
          {
            "hostPort": 0,
            "containerPort": 80,
            "protocol": "tcp"
          }
        ],
        "links": [
          "<APP_NAME>"
        ],
        "environment": [
          {
            "name": "LINK_PORT",
            "value": "<SERVICE_PORT>"
          },
          {
            "name": "LINK_APP",
            "value": "<APP_NAME>"
          }
        ]
      },
      {
        "name": "<APP_NAME>",
        "image": "<IMAGE_NAME>",
        "essential": true,
        "memoryReservation": <MEMORY_RESV>,
        "portMappings": [
          {
            "protocol": "tcp",
            "containerPort": <SERVICE_PORT>
          }
        ],
        "environment": [
          {
            "name": "PORT",
            "value": "<SERVICE_PORT>"
          },
          {
            "name": "APP_NAME",
            "value": "<APP_NAME>"
          }
        ]
      }
    ],
    "requiresCompatibilities": [
      "EC2"
    ],
    "networkMode": "bridge",
    "family": "<APP_NAME>"
  }
# haproxy.cfg

global
    daemon
    pidfile /var/run/haproxy.pid

defaults
    log global
    mode http
    retries 3
    timeout connect 5000
    timeout client 50000
    timeout server 50000

frontend http
    bind *:80

    http-request set-header X-Forwarded-Host %[req.hdr(Host)]

    compression algo gzip
    compression type text/css text/javascript text/plain application/json application/xml

    default_backend app

backend app
    server static "${LINK_APP}":"${LINK_PORT}"
FROM haproxy:1.7
USER root
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg