如何确保wordpress简单的静态插件可以“从172向自己发出请求......"什么时候落后于 traefik 反向代理? [英] How to ensure wordpress simply static plugin can "make requests to itself from 172..." when behind traefik reverse proxy?

查看:37
本文介绍了如何确保wordpress简单的静态插件可以“从172向自己发出请求......"什么时候落后于 traefik 反向代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是 nginx 配置问题、traefik 配置问题还是一般的 docker 网络问题.

I am not sure if this is an nginx config issue, a traefik config issue, or a general docker networking issue.

我假设某处有一个简单的设置可以实现.

I assume there is a simple setting somewhere that will make it possible.

我有 etopian/alpine-php-wordpress 在 traefik 后面运行得很好.

I have etopian/alpine-php-wordpress running great behind traefik.

Simply Static 是一个 wordpress 插件,可以抓取站点并将结果调整为具有相对路径的静态站点.要做到这一点,Wordpress 需要能够向自身发出请求",而简单静态诊断页面给了我一个红色的 X,因为它不能.

Simply Static is a wordpress plugin that crawls the site and adapts the results into a static site with relative paths. To do that Wordpress needs to be able to "make requests to itself", and the Simply Static Diagnostic page gives me a red X because it can't.

我在容器内尝试了一些命令行 wget:

I tried some commandline wgets from within the container:

bash-4.3# wget http://edit.example.com
Connecting to edit.example.com (172.24.x.y:80)
wget: error getting response: Invalid argument
bash-4.3# wget https://edit.example.com
Connecting to edit.example.com (172.24.x.y:443)
wget: can't connect to remote host (172.24.x.y): Connection refused
bash-4.3# wget https://edit.example.com:80
Connecting to edit.example.com:80 (172.24.x.y:80)
wget: can't execute 'ssl_helper': No such file or directory
wget: error getting response: Connection reset by peer

我还尝试向 docker-compose 添加一个额外的主机:

I also tried adding an extra host to docker-compose:

extra_hosts:
  - "edit.example.com:{{actual.ip.add.ress}}

仍然失败,但是Simply Static Diagnostics 中显示的IP 地址更改为机器的外部实际IP(硬编码在上面{{actual.ip.add.ress}} 的位置).

Still fails, but the IP address shown in the Simply Static Diagnostics changes to the external actual ip of the machine (hardcoded where i put {{actual.ip.add.ress}} above).

这些结果让我倾向于使用 nginx 配置修复.似乎edit.adanj.com 已正确解析为docker 容器的内部(或外部)ip,而nginx 不允许连接.

These results make me lean towards an nginx config fix. As it seems that edit.adanj.com is correctly resolved to the internal (or external) ip of the docker container, and nginx is not allowing the connection.

有什么帮助吗?

推荐答案

我找到了一个感觉很黑的解决方案:

I found a solution that feels quite hackish:

extra_hosts:
      - "edit.example.com:172.trae.fik.ip"

在 docker 网络上使用 traefik 容器的完整内部 ip.

Using the full internal ip of the traefik container on the docker network.

我认为问题在于,Simply Static 正在尝试通过 https 发出请求,这通常由 traefik 处理,而 wordpress 容器中的内部 nginx 没有监听 443...所以将这些请求发送到frontdoor 允许 traefik 处理 ssl 业务和请求工作.

I think that the problem was that Simply Static is trying to make requests via https, which is usually handled by traefik, and the internal nginx within the wordpress container is not listening on 443... So sending those requests around to the frontdoor allows traefik to handle the ssl business and the requests work.

好奇是否有其他解决方案...

Curious if there are other solutions...

这篇关于如何确保wordpress简单的静态插件可以“从172向自己发出请求......"什么时候落后于 traefik 反向代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆