使用 jenkins 为 nginx 增加上下文
每次需要在Nginx增加上下文,都需要添加如下两段
server.conf
upstream serverdownloadPage {
server 10.11.19.6:3023;
}
http.conf and https.conf
location ^~ /downloadPage/ {
proxy_redirect off;
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_pass http://serverdownloadPage;
}
既然每次都是重复的内容,只是需要修改部分字符串,当然要想办法用Jenkins去实现了。
脚本如下:
[root@mysql ~]# cat add_server.sh
#!/bin/bash
cat <<EOF>> /usr/local/nginx/conf/vhost/server.conf
upstream server$1 {
server $2:$3;
}
EOF
cat <<EOF> /tmp/vhosts.file
location ^~ /$1/ {
proxy_redirect off;
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_pass http://server$1;
}
EOF
sed -i '36r /tmp/vhosts.file' /usr/local/nginx/conf/vhost/http.conf
sed -i '41r /tmp/vhosts.file' /usr/local/nginx/conf/vhost/https.conf
如何增加上下文呢
./add_server.sh mmp 10.11.19.17 12999


同样Jenkins的配置也就简单了。



使用

使用 jenkins 为 nginx 增加上下文的更多相关文章
- 为nginx增加nginx_http_concat模块
为nginx增加nginx_http_concat模块 时间 2013-06-05 22:14:56 我行我思 原文 http://www.fanjun.me/?p=562 主题 Nginx 缘由 ...
- Nginx 增加 Image 缩略图 功能
Nginx 增加 Image 缩略图功能,需要使用Nginx Image 缩略图 模块 官网地址:https://github.com/3078825/ngx_image_th ...
- Running Jenkins behind Nginx
original : https://wiki.jenkins-ci.org/display/JENKINS/Running+Jenkins+behind+Nginx In situations wh ...
- Debian 为nginx增加第三方模块
为nginx增加第三方模块需要重新编译nginx的,但是debian在安装nginx的时候做了很多事情,比如systemd,/etc/nginx/里的各种文件,所以我们最好在debian源代码包的基础 ...
- jenkins中点击增加云没反应
问题:非容器版jenkins中无法增加云 分析: 之前在jenkins中找自带的Kubernetes 插件找不到,所以就下载Kubernetes 插件进行离线安装,明明显示安装成功了,仍然不能增加云, ...
- nginx增加新模块
以gunzip这个模块为例,讲述一下,在nginx中如何安装新的模块 1.首先查看nginx已经安装了哪些模块. nginx –V 2.发现没有gunzip模块,安装 进入nginx的安装目录中,不是 ...
- nginx填坑补充(nginx根据上下文跳转ip或者域名)
今天有一个需求,要根据上下文调到不同的ip或域名地址,使用上下文做域名跳转的时候,proxy_pass域名后面一定要带‘/’否则会把nginx的上下文自动带入,这样就行. location ^~ /d ...
- Jenkins+Github+Nginx实现前端项目自动部署
前言 最近在搭建一个自己的网站,网站框架搭好了要把项目放到服务器运行,但是每次更新网站内容就要手动部署一次,实在很麻烦,于是就想搭建一套自动化部署的服务.看了一些案例最后选用现在比较主流的Jenkin ...
- nginx增加第三方模块
增加第三方模块 ============================================================ 一.概述nginx文件非常小但是性能非常的高效,这方面完胜ap ...
随机推荐
- playbook常用操作
playbook常用操作 1.检查playbook语法错误 ansible-playbook -i hosts deploy_coredns.yaml --syntax-check 2.查看playb ...
- 前端面试经典题之apply与call的比较
在讲apply和call之前,我们需要先清楚在js中,this指向的是什么. 大家可以参考一下阮一峰老师写的关于JavaScript中this的原理讲解文章:http://www.ruanyifeng ...
- 模型蒸馏(Distil)及mnist实践
结论:蒸馏是个好方法. 模型压缩/蒸馏在论文<Model Compression>及<Distilling the Knowledge in a Neural Network> ...
- java8函数式接口(Functional Interface)
介绍 函数式接口(Functional Interface)就是一个有且仅有一个抽象方法,但是可以有多个非抽象方法的接口. 函数式接口可以被隐式转换为 lambda 表达式(箭头函数). 函数式接口代 ...
- readline安装
wget -c ftp://ftp.gnu.org/gnu/readline/readline-6.2.tar.gz tar -zxvf readline-6.2.tar.gz cd readline ...
- airflow原理
官网: http://airflow.apache.org/installation.html 原理: https://www.cnblogs.com/cord/p/9450910.html 原理介绍 ...
- 2019牛客暑期多校训练营(第六场)-D Move
题目链接:https://ac.nowcoder.com/acm/contest/886/D 题意:给n个物品,每个物品有一个体积值,K个箱子,问箱子的最小体积为多少可将物品全部装下. 思路:比赛时一 ...
- Docker的网络模式和跨主机通信
文章转载自:http://www.a-site.cn/article/169899.html Docker的四种网络模式Bridge模式 当Docker进程启动时,会在主机上创建一个名为docke ...
- 关于tk.mybatis.spring.mapper.SpringBootBindUtil$SpringBoot2Bind.bind(SpringBootBindUtil.java:129) ~[mapper-spring-boot-autoconfigure-1.2.3.jar:na]的问题
错误如下: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at tk.mybatis.spring.m ...
- CrawlerRunner没有Log输出
官网log说明:https://docs.scrapy.org/en/latest/topics/logging.html#scrapy.utils.log.configure_logging 这里记 ...