云客户?
免费开始>
在MyJFrog中升级>
云的新功能>





设置Apache HTTP服务器

使用HTTP

Apache HTTP服务器使用AJP协议

从Artifactory版本7.0开始,不支持AJP连接器。

您可以使用HTTP协议将Apache HTTP Server设置为Artifactory的前端。

客户端  ----------> HTTPD  ----------> Artifactory HTTP HTTP
页面内容

在使用Tomcat运行Artifactory时,我们建议您将Apache设置为通过HTTP代理Artifactory。

您必须使用PassReverse指令正确地配置重定向,并且还要在Artifactory本身中设置基本URL,以便UI链接正确显示。

示例虚拟主机假设Artifactory监听端口8081,所有其他服务和UI都在端口8082上可用。

确保HTTP重定向工作正确

为了使HTTP重定向工作,您必须在Apache上设置PassReverse指令,否则底层容器基础URL将在重定向中传递

在下面的示例中,它被设置为http://yourdomain.com/

在Apache上设置PassReverse指令
 ServerName yourdomain.com ServerAlias *.yourdomain.com ServerAdmin server@admin ##应用特定日志## ErrorLog ${APACHE_LOG_DIR}/yourdomain.com-error.log ## CustomLog ${APACHE_LOG_DIR}/yourdomain.com-access.log组合AllowEncodedSlashes On RewriteEngine On RewriteCond %{SERVER_PORT} (.*) RewriteRule (.*) - [E=my_server_port:%1] ##注意:RewriteCond %{REQUEST_SCHEME} (.*) RewriteRule (.*) - [E=my_scheme:%1] RewriteCond %{HTTP_HOST} (.*) RewriteRule (.*) - [E=my_custom_host:%1] RewriteRule ^(/)?$ /ui/ [R,L] RequestHeader set Host %{my_custom_host}e RequestHeader set X-Forwarded-Port %{my_server_port}e ##{my_scheme}需要一个仅支持apache 2.4及以上版本的模块RequestHeader set X-Forwarded-Proto %{my_scheme}e RequestHeader set x - jfrog - over- base - url %{my_scheme}e://yourdomain.com:%{my_server_port}e ProxyPassReverseCookiePath // ProxyRequests off ProxyPreserveHost on ProxyPass "/artifactory/" http://:8081/artifactory/ connectiontimeout=5 timeout=2400 ProxyPassReverse "/artifactory/" http://:8081/artifactory/ ProxyPass "/"http://:8082/ nocanon connectiontimeout=5 timeout=2400 ProxyPassReverse "/" http://:8082/ 

NPM作用域包和Apache反向代理

要使用NPM作用域的包,您必须在Apache反向代理配置的SERVER块中应用以下配置。

  • AllowEncodedSlashes“NoDecode”。

    AllowEncodedSlashes NoDecode


  • 添加"nocanon"关键字到ProxyPassProxyPassReverse指令。

    ProxyPass /artifactory/ http://localhost:8081/artifactory/ nocanon ProxyPassReverse /artifactory/ http://localhost:8081/artifactory/ nocanon



使用HTTPS

您可以使用HTTP协议将带有SSL (HTTPS)的Apache设置为Artifactory的前端。

客户端  ----------> HTTPD  ----------> Artifactory HTTPS HTTP
Apache上配置SSL/TLS
 SSLEngine on SSLCertificateFile path/to/yourdomain.com.crt SSLCertificateKeyFile path/to/yourdomain.com.key SSLProxyEngine on ##附加反向代理指令

在Artifactory中配置自定义基URL

当使用HTTP代理时,Artifactory生成的链接以及某些重定向可能包含错误的端口和用法http而不是https

因此,您必须按照如下方式配置自定义基URL:

  1. 管理选项卡选择配置|总则自定义基础URL字段。
  2. 设置自定义基础URL字段设置为用于联系Artifactory的值
    例如:https://yourdomain.com

请参考一般系统设置以获取有关配置基本URL的更多详细信息。

版权所有©2022 JFrog Ltd.