大网数据广告活动
服务器运维问答

apache mod_rewrite / mod_proxy adds port 443 to proxy url on https to http

· 52CE 我爱测

We are using mod_rewrite with mod_proxy to proxy requests by crawlers and bots to prerender.io. The prerender service does not support https currently, but my clients site only does, so the proxy is from https to http. This used …

问题原文

原帖链接 · Richard Naeve · CC BY-SA 4.0

We are using mod_rewrite with mod_proxy to proxy requests by crawlers and bots to prerender.io. The prerender service does not support https currently, but my clients site only does, so the proxy is from https to http. This used to work fine but since we updated to Apache 2.4.29 the proxy urls always have port 443 added.

Old: https://www.example.com/news/something -> http://service.prerender.io/https://www.example.com/news/something
New: https://www.example.com/news/something -> http://service.prerender.io:443/https://www.example.com/news/something

How can I revert back to the old behavior without reverting apache?

Heres the .htaccess code:

RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|baiduspider|rogerbot|embedly|quora\ link\ preview|showyoubot|outbrain [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Yandex(Bot|Images|Video|Media) [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_

RewriteRule ^(.*)$ http://service.prerender.io/https://%{HTTP_HOST}$1 [P,L]

已采纳解答

原帖链接 · Richard Naeve · CC BY-SA 4.0

The answer is very straight forward and easy, probably why I missed it.

Just add port 80 to the proxy url:

RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|baiduspider|rogerbot|embedly|quora\ link\ preview|showyoubot|outbrain [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Yandex(Bot|Images|Video|Media) [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_

RewriteRule ^(.*)$ http://service.prerender.io:80/https://%{HTTP_HOST}$1 [P,L]

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-04-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。