nginx-reverse-proxy - 设置 Docker 存储库端口
问题描述
一直致力于设置 JFrog Container Repository,并且在设置 Docker Repository Ports 时遇到了问题。
我已经完成并将 Nginx 设置为反向代理,并生成了一个工作站点可用的 conf 文件
## add ssl entries when https has been set in config
ssl_certificate /etc/nginx/ssl/secret.crt;
ssl_certificate_key /etc/nginx/ssl/secret.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers on;
## server configuration
server {
listen 443 ssl;
listen 80 ;
server_name subdomain.domain.com;
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
## Application specific logs
## access_log /var/log/nginx/artifactory.jfrog.com-access.log timing;
## error_log /var/log/nginx/artifactory.jfrog.com-error.log;
rewrite ^/$ /artifactory/webapp/ redirect;
rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
chunked_transfer_encoding on;
client_max_body_size 0;
location / {
proxy_read_timeout 900;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
if ( $request_uri ~ ^/artifactory/(.*)$ ) {
proxy_pass http://localhost:8081/artifactory/$1;
}
proxy_pass http://localhost:8081/artifactory/;
proxy_set_header X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
我可以查看页面、登录、创建存储库……等等……
但是当我转到 docker 存储库的 Advanced 选项卡尝试设置 HTTP 设置时,我仍然会看到“要使用此功能首先配置反向代理”。即使我当时正在通过反向代理查看页面。
我不知道我是否遗漏了一些超级简单的东西,或者我只是遇到了某种错误。我查看了 JFrog jira,似乎找不到任何符合此描述的内容。
任何帮助将不胜感激。
谢谢!
编辑:
可能还应该留下一些系统信息......
OS: Centos 7
Nginx: 1.16.1
JCR: 6.17.0-61700900
解决方案
这是一个错误。我已经为您提交了 RTFACT-21197。也就是说,它只是一个生成器,您可以简单地编辑现有配置。对于端口,您需要做的就是复制/粘贴并添加一个带有存储库名称的 docker 行。例如,假设您有一个名为 docker-local 的存储库,并且您希望在端口 5000 上可以访问它,您的最终配置将如下所示:
## add ssl entries when https has been set in config
ssl_certificate /etc/nginx/ssl/secret.crt;
ssl_certificate_key /etc/nginx/ssl/secret.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers on;
## server configuration
server {
listen 443 ssl;
listen 80 ;
server_name subdomain.domain.com;
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
## Application specific logs
## access_log /var/log/nginx/artifactory.jfrog.com-access.log timing;
## error_log /var/log/nginx/artifactory.jfrog.com-error.log;
rewrite ^/$ /artifactory/webapp/ redirect;
rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
chunked_transfer_encoding on;
client_max_body_size 0;
location / {
proxy_read_timeout 900;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
if ( $request_uri ~ ^/artifactory/(.*)$ ) {
proxy_pass http://localhost:8081/artifactory/$1;
}
proxy_pass http://localhost:8081/artifactory/;
proxy_set_header X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 5000 ssl;
server_name subdomain.domain.com;
if ($http_x_forwarded_proto = '') {
set $http_x_forwarded_proto $scheme;
}
rewrite ^/$ /artifactory/webapp/ redirect;
rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
rewrite ^/(v1|v2)/(.*) /artifactory/api/docker/docker-local/$1/$2;
chunked_transfer_encoding on;
client_max_body_size 0;
location / {
proxy_read_timeout 900;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
if ( $request_uri ~ ^/artifactory/(.*)$ ) {
proxy_pass http://localhost:8081/artifactory/$1;
}
proxy_pass http://localhost:8081/artifactory/;
proxy_set_header X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
推荐阅读
- ios - 如何从 Windows 在 Iphone 模拟器中部署应用程序
- c++ - 哪些整数运算不安全?
- java - 为什么我的代码不计算字符串的第一个单词
- c# - 自定义 ASP.NET 图表的样式
- python - 查找具有共同起始元素的子列表 - python
- angular - 跨设备渲染 Angular 的实时变化
- hyperledger-fabric - 无法在 Composer Rest Server 中过滤数据
- authentication - ODBC 中的 InitString SqlAnywhere 12 身份验证
- python - 类型提示会提高 Python 的性能吗?
- animation - 使用 react-native Animated 为 Svg.G 制作动画