【问题标题】:Apache proxy redirects from HTTPS to HTTPApache 代理从 HTTPS 重定向到 HTTP
【发布时间】:2018-03-08 21:17:23
【问题描述】:

下面是使用“ProxyPass”和“ProxyPassReverse”的apache反向代理配置sn-p

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”

如果我使用“/artifactory/webapp/#/home”运行 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。

【问题讨论】:

    标签: apache reverse-proxy artifactory


    【解决方案1】:

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

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

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

    【讨论】:

    • 谢谢爱丽儿。是否需要将此重写规则添加到两个部分(80 和 443)..?并且由于这个 apache 也被其他服务使用,是否会首先重写线路影响在 80/443 部分中定义的其他服务。?我有 Artifactory 的企业版。由于依赖此 apache 代理的服务太多,我无法使用 sn-p 生成的代理配置,并且我不想通过添加 sn-p 生成的配置来破坏/影响其他服务。运行 apache 2.2 的代理是不按原样添加 sn-p 配置的另一个原因。 2.2 可能不支持某些参数。
    猜你喜欢
    • 2016-01-17
    • 2018-04-09
    • 2019-12-17
    • 2017-07-10
    • 1970-01-01
    • 2013-09-27
    • 2016-02-04
    • 2016-09-30
    • 2019-11-08
    相关资源
    最近更新 更多