【问题标题】:Artifactory pro server behind an nginx frontendnginx 前端背后的 Artifactory pro 服务器
【发布时间】:2016-02-19 08:25:09
【问题描述】:

我正在尝试为我们的工件服务器设置 ssl。为此,我希望将 nginx 配置为反向代理。到目前为止,我已经完成了以下操作

-- 使用 docker 镜像安装 artifactory pro

docker run --name artifactory-registry -p 8081:8081 -v $ARTIFACTORY_HOME/data -v $ARTIFACTORY_HOME/logs  -v $ARTIFACTORY_HOME/backup  -v $ARTIFACTORY_HOME/etc  jfrog-docker-reg2.bintray.io/jfrog/artifactory-pro:latest

-- 使用sudo apt-get install nginx安装 nginx

我可以通过http://localhost:8081/artifactory/webapp/#/home 访问网络应用程序 以及 $ARTIFACTORY_HOME/tomcat/conf/server.xml 下的配置文件

<Service name="Catalina">
    <Connector port="8081"/>

    <!-- This is the optional AJP connector -->
    <Connector port="8019" protocol="AJP/1.3"/>

    <Engine name="Catalina" defaultHost="localhost">
        <Host name="localhost" appBase="webapps"/>
    </Engine>

</Service>

从网上找的资料来看,nginx做反向代理需要如下配置

server {
  listen          80;
  server_name     yourdomain.com;
  root            /etc/tomcat7/webapps/apple;

  proxy_cache one;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
  }
} 

这个路径中的“server_name”和“root”应该是什么?另外,如何测试此设置的反向代理?

【问题讨论】:

    标签: nginx https docker artifactory


    【解决方案1】:

    通常您将在其默认的 HTTPS 端口 (443) 上配置 SSL。 看看this page 使用 SSL 配置 nginx。

    server_name 是您将连接到 nginx 的主机(例如从浏览器)。通常你会有一个来自你公司的 DNS 地址(比如artifactory.mycompany.com)并且你会使用它,但如果一切都是本地的,你可以只用localhost 代替。 这是端口 443 上的有效 SSL 配置:

    server {
        listen 443;
        server_name artifactory.mycompany.com;
    
        access_log /var/log/nginx/artifactory.access.log;
        error_log /var/log/nginx/artifactory.error.log;
    
        ssl on;
        ssl_certificate /etc/nginx/ssl/artifactory.crt;
        ssl_certificate_key /etc/nginx/ssl/artifactory.key;
    
        ssl_session_timeout 5m;
    
        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
        ssl_prefer_server_ciphers on;
    
        location /artifactory {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Ssl on;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://localhost:8081;
            proxy_pass_header Server;
            proxy_read_timeout 90;
        }
    }
    

    只需将您的 SSL 证书放在配置的位置即可。

    现在应该可以从您的浏览器连接到 https://artifactory.mycompany.com(或 https://localhost,如果您将其用于 server_name)。

    【讨论】:

    • 嗨@shayy 为什么位置是 /artifactory 而不仅仅是 /
    猜你喜欢
    • 2013-09-06
    • 1970-01-01
    • 2012-07-11
    • 2016-03-10
    • 1970-01-01
    • 2020-11-02
    • 2011-06-15
    • 1970-01-01
    • 2017-05-28
    相关资源
    最近更新 更多