繁体   English   中英

如何将 apache2 链接到 wordpress docker 容器?

[英]How to link apache2 to a wordpress docker container?

我有两个 docker 容器(一个用于 mysql,另一个用于 wordpress)。 它看起来像这样。

在此处输入图像描述

我想将我的域 (example.com) 链接到 wordpress 容器。 到目前为止,我想出了这个 apache 配置文件。

<VirtualHost *:80>
ServerAdmin hello@example.com
ServerName example.com
    ServerAlias www.example.com
    ProxyRequests off
<Proxy *>
        Order deny,allow
        Allow from all
</Proxy>
<Location />
        ProxyPass http://localhost:4568/
        ProxyPassReverse http://localhost:4568/
</Location>
</VirtualHost>

Now, example.com works just fine for the home page but when I try to go to directory (say, http://example.com/product/asdasd ) it redirects me to http://localhost/product/asdasd.

我尝试用域名更改配置文件中的 localhost 但它不起作用;

ProxyPass http://example.com:4568/
ProxyPassReverse http://example.com:4568/

谁能帮我弄清楚这样做的正确配置文件是什么?

谢谢

我复制并让它工作。

您需要在wp-config.php中添加这些行:

define('WP_HOME', 'http://www.example.com/');
define('WP_SITEURL', 'http://www.example.com/'); `

这是我的示例的 apache 配置文件。com 域:

<VirtualHost *:80>
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>
  ProxyPreserveHost On
  RequestHeader set X-Forwarded-Proto "http"
  ProxyPass / http://localhost:4568/
  ProxyPassReverse / http://localhost:4568/
  <Location />
    Order allow,deny
    Allow from all
  </Location>
</VirtualHost>

在这些更改之后,WP 立即停止重定向到localhost

在此处输入图像描述

如果您仍然遇到任何问题,请发表评论,我将尝试使用我在 apache 配置上执行的其他更改来更新帖子,尽管这些不应该相关。

要使用 example.com:4568,您需要公开端口 4568 或者您可以将 /etc/hosts 中的条目设置为localhost:4568 example.com以保持其私有

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM