简体   繁体   English

为什么当流量从反向代理(端口 8080)转发到 Wordpress 站点侦听端口 80 时,浏览器中的 URL 会发生变化

[英]Why does URL change in browser when traffic forwarded from Reverse Proxy (port 8080) to Wordpress site listening on port 80

I'm testing a 3rd party vendor Reverse Proxy to be able to forward traffic to various web servers on the backend.我正在测试第三方供应商反向代理,以便能够将流量转发到后端的各种 web 服务器。 In this particular case, the RP is listening on port 8080 and based on the URL it detects (abc.example.com:8080/abc), it'll pass on the traffic to the a backend server for eg: 192.168.0.60 listening on port 80. Now when I type the the address in the web browser as follows: abc.example.com:8080/abc, the response comes back with connection time out and the URL has changed to abc.example.com/abc in the browser.在这种特殊情况下,RP 正在侦听端口 8080 并基于它检测到的 URL (abc.example.com:8080/abc),它将流量传递到后端服务器 0.60 例如:192.168 监听。 on port 80. Now when I type the the address in the web browser as follows: abc.example.com:8080/abc, the response comes back with connection time out and the URL has changed to abc.example.com/abc in浏览器。 It basically strips off the port from within the URL.它基本上从 URL 中剥离了端口。 The browser then tries to connect to abc.example.com/abc but can't get anywhere since there is no path directly to the backend server.然后浏览器尝试连接到 abc.example.com/abc 但无法到达任何地方,因为没有直接到后端服务器的路径。

Following is the .htaccess configuration on the backend server running WAMP以下是运行 WAMP 的后端服务器上的 .htaccess 配置

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /abc/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /abc/index.php [L]
</IfModule>

Any idea why this might be happening?知道为什么会发生这种情况吗?

Add the following to your wp-config.php:将以下内容添加到您的 wp-config.php:

define( 'WP_HOME', 'http://abc.example.com:8080' );
define( 'WP_SITEURL', 'http://abc.example.com:8080' );

On startup, Wordpress checks whether the given URL matches the defined URL for the site and if it does not match then Wordpress performs a redirect. On startup, Wordpress checks whether the given URL matches the defined URL for the site and if it does not match then Wordpress performs a redirect. So, I think your Wordpress is performing the redirect because it is does not consider ":8080" to be part of its defined site URL.因此,我认为您的 Wordpress 正在执行重定向,因为它不认为“:8080”是其定义的站点 URL 的一部分。

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

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