2017-09-27 147 views
0

下面是使用 “的ProxyPass” 和 “ProxyPassReverse”Apache代理从HTTPS重定向到HTTP

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命令,以某种方式将其重定向apache的反向代理配置片段到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” 

如果我运行 “/ artifactory的/ web应用/#/家” 它https使用wget命令:

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。

回答

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配置代码片段。

+0

谢谢阿里尔。这个重写规则是否需要添加到这两个部分(80和443)..?而且由于这个apache也被其他服务所使用,将首先重写线路影响在80/443节中定义的其他服务。我有Artifactory的企业版。我不能使用snippet生成的代理配置,因为太多的服务依赖于这个apache代理,我不想通过添加snippet生成的配置来打破/影响其他服务。运行apache 2.2的代理是不按原样添加snippet配置的另一个原因。 2.2可能不支持某些参数。 – Pushpraj