gpt4 book ai didi

nginx - Jenkins Https 反向代理配置在 centos 中不起作用

转载 作者:行者123 更新时间:2023-12-04 22:39:00 40 4
gpt4 key购买 nike

我已经在 centos 中安装了 nginx 和 jenkins 服务器。我想用 https 连接我的 Jenkins 服务器。所以我已经配置了反向代理。但它不起作用,我收到以下错误
enter image description here
以下是我的配置值
文件 -/etc/nginx/sites-enabled/default

server {
listen 80;
return 301 https://$host$request_uri;
}
server {

listen 443;
server_name 134.68.44.235;

ssl_certificate /etc/nginx/cert.crt;
ssl_certificate_key /etc/nginx/cert.key;

ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;

access_log /var/log/nginx/jenkins.access.log;

location / {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_pass http://localhost:8080;
proxy_read_timeout 90;

proxy_redirect http://localhost:8080 https://134.68.44.235;
}
}
文件/etc/default/jenkins
JENKINS_ARGS="--webroot=/var/cache/jenkins/war --httpListenAddress=127.0.0.1 --httpPort=$HTTP_PORT -ajp13Port=$AJP_PORT"
注意:我可以使用 http://134.68.44.235:8080 访问 jenkins 站点
但我无法使用 https 访问它,我安装了证书并按照步骤 from this article
我不确定我错过了什么,任何人都请给我建议。

最佳答案

下面的这段代码应该可以正常工作,您必须编辑内容部分以匹配您希望 Jenkins 为 Web UI 提供服务的 FQDN 或 IP,以及有效的 SSL CERT 路径和 SSL KEY 路径(如果您想提供 https)。

upstream app_server {
server 127.0.0.1:8080 fail_timeout=3;
}

server {
listen 80;
server_name <FQDN OR IP>;
return 301 https://$server_name$request_uri;
}

server {
listen 443;
server_name <FQDN OR IP>;

ssl on;
ssl_certificate /<PATH>/<TO>/<YOUR SSL CERT>;
ssl_certificate_key /<PATH>/<TO>/<YOUR SSL KEY>;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

# Redirect any /* request to port 8080
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range,Location';
}

proxy_redirect http:// https://;
proxy_pass http://app_server;
}
}

关于nginx - Jenkins Https 反向代理配置在 centos 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69915927/

40 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com