Apache代理从HTTPS重定向到HTTP

时间:2017-09-27 11:40:19

标签: apache reverse-proxy artifactory

以下是使用" ProxyPass"和#34; ProxyPassReverse"

Listen 1.2.3.4:80
<VirtualHost 1.2.3.4:80>
  ProxyPreserveHost On
  SSLProxyEngine On
  ProxyPass /artifactory https://xxxx.xxxx.xxx/artifactory 
  ProxyPassReverse /artifactory https://xxxx.xxxx.xxx/artifactory 

Listen 1.2.3.4:443
<VirtualHost 1.2.3.4:443>
  SSLProxyEngine On
  ProxyPreserveHost On
  ProxyPass /artifactory https://xxxx.xxxx.xxx/artifactory
  ProxyPassReverse /artifactory https://xxxx.xxxx.xxx/artifactory
</VirtualHost>   

当我在wget命令下运行时,它会以某种方式重定向到http:

#wget --no-check-certificate "https://xxxx.xxxx.xxx/artifactory/"
--2017-09-27 06:25:50--  
https://xxxx.xxxx.xxx/artifactory/
Resolving xxxx.xxxx.xxx... 1.2.3.4
Connecting to xxxx.xxxx.xxx|1.2.3.4|:443... connected.
WARNING: certificate common name “xxxx.xxxx.xxx” doesn't match requested 
host name “xxxx.xxxx.xxx”.
HTTP request sent, awaiting response... 302 Found
Location: http://xxxx.xxxx.xxx/artifactory/webapp/ [following]
--2017-09-27 06:25:51--  
http://xxxx.xxxx.xxx/artifactory/webapp/
Connecting to xxxx.xxxx.xxx|1.2.3.4|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1449 (1.4K) [text/html]
Saving to: “index.html.18”

如果我用&#34; / artifactory / webapp /#/ home&#34;运行wget命令它适用于https:

wget --no-check-certificate "https://xxxx.xxxx.xxx/artifactory/webapp/#/home"
--2017-09-27 06:12:48-
https://xxxx.xxxx.xxx/artifactory/webapp/
Resolving xxxx.xxxx.xxx... 1.2.3.4
Connecting to xxxx.xxxx.xxx|1.2.3.4|:443... connected.
WARNING: certificate common name “xxxx.xxxx.xxx” doesn't 
match requested host name “xxxx.xxxx.xxx”.
HTTP request sent, awaiting response... 200 OK
Length: 1449 (1.4K) [text/html]
Saving to: “index.html.17”

2017-09-27 06:12:49 (73.1 MB/s) - “index.html.17” saved [1449/1449]

我没有在代理配置文件中的任何位置定义重定向。

有人可能会建议这种行为背后的原因。以及如何避免将其重定向到HTTP。?

1 个答案:

答案 0 :(得分:0)

您似乎已将反向代理配置为侦听以“/ artifactory”结尾的网址。 考虑添加以下内容:

RewriteRule ^/$                     /artifactory/webapp/ [R,L]
RewriteRule ^/artifactory(/)?$      /artifactory/webapp/ [R,L]
RewriteRule ^/artifactory/webapp$   /artifactory/webapp/ [R,L]

另外,您使用的是Artifactory OSS还是Pro?如果是Pro,您可以选择直接从Artifactory生成Apache配置代码段。