假设 nginx 在目标服务器已经安装好了。没有安装好的,参考[《centos7 安装 jdk ,maven,tomcat,nginx》](https://www.yuque.com/docs/share/954a9630-ae57-4fb0-aff5-cf6371942352?# 《centons7 安装 jdk ,maven,tomcat,nginx》)。
1>/etc/nginx/conf.d //进入到nginx 配置目录下
2>创建文件名为: jenkins.conf
#jenkins.leader755.com
server {
listen 80;
server_name jenkins.leader755.com;
return 301 https://$server_name$request_uri;
}
server{
listen 443 ssl;
server_name jenkins.leader755.com;
#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
ssl_certificate /etc/nginx/cert/jenkins.leader755.com/jenkins.leader755.com.pem; # pem文件的路径
ssl_certificate_key /etc/nginx/cert/jenkins.leader755.com/jenkins.leader755.com.key; # key文件的路径
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#Location配置
location / {
proxy_set_header X-Rea $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://localhost:8081; # 此处改为 8081,取决于自己之前访问的ip地址的端口号
proxy_set_header X-Forwarded-Proto $scheme;
}
}
1.保存修改并重启nginx
1>ESC+:wq(退出并保存)
2>[root@localhost nginx]# sudo nginx -t // 验证书写是否正确
3>[root@localhost nginx]# nginx -s reload //重启
//或者使用下面
4>[root@localhost nginx]# killall -9 nginx //强制杀死所有的 nginx 进程
5>[root@localhost ~]# service nginx start //sha
如果有问题的,请参考《centos7 安装 jdk ,maven,tomcat,nginx》