简体   繁体   English

Wordpress 反向代理

[英]Wordpress Reverse Proxy

I am trying to reverse proxy example.com to production.example.com which lives on a different server.我正在尝试将 example.com 反向代理到 production.example.com,它位于不同的服务器上。 However after adding proxy rules (apache) on the main domain and adding below on production.example.com wp-config.php但是,在主域上添加代理规则(apache)并在 production.example.com wp-config.php 上添加以下内容后

define( 'WP_SITEURL', "https://example.com/" );

I was able to load the site without any issue.我能够毫无问题地加载该网站。 However when i try to click on a post, the post loads from production.example.com但是,当我尝试单击帖子时,该帖子会从 production.example.com 加载

Example : https://production.example.com/hello-world/

How can i fix this issue letting the site to load on siteurl instead.我该如何解决这个问题,让网站改为在 siteurl 上加载。

Considering that example.com is your external domain.考虑到 example.com 是您的外部域。

In the database (or ui directly) I had to update both siteurl and home在数据库(或直接 ui)中,我必须同时更新siteurlhome

update wp_options set option_value="https://example.com" where option_name in ("siteurl", "home");

Pasting also the reverse proxy settings for apache:还粘贴 apache 的反向代理设置:

<VirtualHost *:443>
  ServerName example.com
  SSLEngine on
  SSLCertificateFile "/sslcert/server.crt"
  SSLCertificateKeyFile "/sslcert/server.key"

   ProxyRequests Off
   KeepAlive Off
   <Proxy *>
      Order deny,allow
      Allow from all
   </Proxy>

   # These are required for https reverse proxy to work   
   RequestHeader set X-Forwarded-Proto "https"
   RequestHeader set X-Forwarded-Port "443"   

   ProxyPass / http://non-public-address/
   ProxyPassReverse / http://non-public-address/
   ProxyPreserveHost On
   ErrorLog "logs/wordpress.revproxy-sslerror_log"
   CustomLog "logs/wordpress.revproxy-sslaccess_log" common
</VirtualHost>

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

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