# spring-boot 项目配置代理
server {
listen 80;
server_name start.spring.io;
access_log logs/spring-boot.log;
error_log logs/spring-boot.error;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8082/;
}
}
# 内网转发(upstream) jenkins
#upstream作负载均衡,在此配置需要轮询的服务器地址和端口号,
#max_fails为允许请求失败的次数,默认为1.
#weight为轮询权重,根据不同的权重分配可以用来平衡服务器的访问率。
#指定要域名对应的WEB项目访问地址
upstream jenkins {
server 10.0.0.20:8080 max_fails=0 weight=1;
server 10.0.0.20:8080 backup;
}
#主机配置
server {
#监听端口
listen 80;
#自己指定要跳转的域名
server_name jenkins.project.com;
#字符集
charset utf-8;
#单独的access_log文件
access_log logs/jenkins.access.log main;
#反向代理配置,
#将所有请求为http://jenkins的请求全部转发到upstream中定义的目标服务器中。
location / {
#此处配置的域名必须与upstream的域名一致,才能转发。
proxy_pass http://jenkins;
proxy_set_header X-Real-IP $remote_addr;
}
#启用nginx status 监听页面
location /nginxstatus {
stub_status on;
access_log on;
}
#错误页面
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}