nginx 配置域名转发
自己测试环境,配置下载目录和一个jenkins的地址:
域名跳转,反向代理
# cat ../nginx.conf
user www www;
worker_processes ;
error_log logs/error.log info;
pid logs/nginx.pid;
worker_rlimit_nofile ;
events {
worker_connections ;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'"$upstream_addr" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$request_time" "$host"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout ; gzip on;
client_max_body_size 50m; #缓冲区代理缓冲用户端请求的最大字节数,可以理解为保存到本地再传给用户
client_body_buffer_size 256k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
proxy_connect_timeout 300s; #nginx跟后端服务器连接超时时间(代理连接超时)
proxy_read_timeout 300s; #连接成功后,后端服务器响应时间(代理接收超时)
proxy_send_timeout 300s;
proxy_buffer_size 64k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 32k; #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置
proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*)
proxy_temp_file_write_size 64k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传递请求,而不缓冲到磁盘
proxy_ignore_client_abort on; #不允许代理端主动关闭连接 upstream tomcat_test1 {
server 192.168.37.108:;
} upstream tomcat_2 {
server 192.168.37.109:;
} include /usr/local/nginx/conf/vhosts/*.conf;
}
接下来是server 主机的配置:
# cat /usr/local/nginx/conf/vhosts/test.conf
server {
listen ;
server_name www.aliluo.top; location /images {
root /;
rewrite ^/image/(.*)$ /image/$ break;
access_log /usr/local/nginx/logs/test.log main;
}
location /upload {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
alias /data/upload;
access_log /usr/local/nginx/logs/upload.log main;
}
location /jenkins {
#反向代理的地址
proxy_pass http://tomcat_2/jenkins;
#设置主机头和客户端真实地址,以便服务器获取客户端真实IP
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
access_log /usr/local/nginx/logs/tomcat_test1.log main;
} }
启动nginx后,打来链接,就会出现jenkins界面,输入用户名,密码可以正常登陆:

登陆页面:

备注:
1)使用nginx的rewrite 同样可以是实现这个功能,可能配置上会有小许不同;
2)使用proxy_pass,如果跳转后输入用户名密码无法登陆,可能是由于以下参数没有配置,该参数具体含义可以参考nginx有关文章自行学习:
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
nginx 配置域名转发的更多相关文章
- Nginx配置域名转发实例
域名:cps.45wan.com 所在阿里云主机:123.35.9.12 45wan没有在阿里云备案 67wan已经在阿里云备案 阿里云主机(假如123.35.9.12)上原来的nginx配置: ...
- Nginx配置proxy_pass转发的/路径问题
Nginx配置proxy_pass转发的/路径问题 在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则 ...
- 使用nginx配置域名及禁止直接通过IP访问网站
前段时间刚搭建好个人网站,一直没有关注一个问题,那就是IP地址也可以访问我的网站,今天就专门研究了一下nginx配置问题,争取把这个问题研究透彻. 1. nginx配置域名及禁止直接通过IP访问 先来 ...
- nginx安装配置域名转发
1.安装pcre 1.[root@localhost home]# tar zxvf pcre-8.10.tar.gz //解压缩 2.[root@localhost home]# cd pcre-8 ...
- nginx配置https转发到tomcat(使用自签名的证书)
一.使用openSSL生成自签名的证书 1.生成RSA私钥 命令:openssl genrsa -des3 -out server.key 1024 说明:生成rsa私钥,des3算法,1024强度, ...
- nginx 配置301转发
学习nginx 推荐 http://www.nginx.cn/nginx-how-to 1. 设置域名解析 daijun.me 指向 234.33.22.21 2.主机234.33.22.21 ngi ...
- Nginx配置proxy_pass转发的/路径
请求原地址 :http://servername/static_js/test.html location ^~ /static_js/ { proxy_cache js_cache; proxy_s ...
- nginx配置https转发http
生成ssl证书: 1.首先要生成服务器端的私钥,运行时会提示输入密码,此密码用于加密key文件: openssl genrsa -des3 -out server.key 1024 2.去除key文件 ...
- .NET 反向代理 YARP 通过编码方式配置域名转发
前面介绍了 YARP 通过配置文件的方式配置代理转发(传送门),而众所周知,微软的一贯作风就是能通过配置文件做的事情,通过编码的方式也能实现!YARP 也不例外,废话不多说,直接上代码! 首先,参照官 ...
随机推荐
- 基于jieba,TfidfVectorizer,LogisticRegression进行搜狐新闻文本分类
一.简介 此文是对利用jieba,word2vec,LR进行搜狐新闻文本分类的准确性的提升,数据集和分词过程一样,这里就不在叙述,读者可参考前面的处理过程 经过jieba分词,产生24000条分词结果 ...
- Map_占位符(嗨没想好怎么起名字)
Map 是很好的集合,为我们带来了在其他语言(比如 Perl)中经常可见的好用的键/值对集合.JDK 以 HashMap 的形式为我们提供了方便的 Map 实现,它在内部使用哈希表实现了对键的对应值的 ...
- java io系列12之 BufferedInputStream(缓冲输入流)的认知、源码和示例
本章内容包括3个部分:BufferedInputStream介绍,BufferedInputStream源码,以及BufferedInputStream使用示例. 转载请注明出处:http://www ...
- MyBatis-generator-Maven方式
一.配置依赖 1.依赖信息 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project x ...
- twitter分布式主键id生成器
pom <!--生成id--> <dependency> <groupId>com.github.bingoohuang</groupId> <a ...
- Sql Server 游标例子笔记
create PROCEDURE total_mySaleDuty as BEGIN DECLARE @a int,@error int DECLARE @b int,@errorb int DECL ...
- ThinkSNS2.5前台getshell+后台任意文件删除
12年爆出的一个洞 前几天比赛的一个cms 于是跟出题人表哥要过来审计了看看 漏洞文件再根目录thumb.php中 <?php /* * 自动缩略图 参数 url|w|h|type=" ...
- Hive基础概念、安装部署与基本使用
1. Hive简介 1.1 什么是Hive Hives是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供类SQL查询功能. 1.2 为什么使用Hive ① 直接使用 ...
- Uncaught TypeError: $(…).orgcharts is not a function
调整js顺序没有解决,最后增加NoConflict解决,注意红色部分 function initorgcharts() { var $jq = jQuery.noConflict(true); org ...
- PMD -- An extensible cross-language static code analyzer.
PMD An extensible cross-language static code analyzer. https://github.com/pmd/pmd 跨语言静态代码分析工具.可以查找通用 ...