nginx 反向代理测试
来源:互联网 发布:js怎么获取css样式 编辑:程序博客网 时间:2024/06/05 13:27
代理机器:192.168.163.128
后端机器:192.168.163.129和192.168.163.131
以上三台机器都搭建了nginx
1、修改index.html,区别后端机器
192.168.163.129和192.168.163.131上的/usr/local/nginx/html/index.html中,修改Welcome to nginx 为Welcome to nginx129和Welcome to nginx131以作这两台机器的区别
2、代理机器的配置
修改nginx.conf文件:
http { include mime.types; default_type application/octet-stream; include /usr/local/nginx/conf/reverse-proxy.conf; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; 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 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的话,这样设置 proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2) proxy_temp_file_write_size 64k; #设定缓存文件夹大小,大于这个值,将从upstream服务器传递请求,而不缓冲到磁盘 proxy_ignore_client_abort on; #不允许代理端主动关闭连接 #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}3、添加conf/reverse-proxy.conf文件
server{ listen 80; server_name 123.tk; location / { 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://192.168.163.129:80; } access_log logs/123.tk_access.log;}server{ listen 80; server_name 456.tk; location / { 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://192.168.163.131:80; } access_log logs/456.tk_access.log;}
4、重载nginx
kill -HUP `cat /usr/local/nginx/nginx.pid`
5、修改访问机器的hosts
在要访问这些域名的机器上修改hosts文件,添加:
192.168.163.129 123.tk
192.168.163.131 456.tk
6、测试访问
1 0
- nginx 反向代理测试
- Nginx反向代理测试记录
- nginx搭建反向代理配置并测试
- Nginx反向代理Nginx
- Nginx反向代理Nginx
- nginx最简单地反向代理负载均衡配置测试
- Nginx HTTP负载均衡/反向代理的相关参数测试
- Nginx HTTP负载均衡/反向代理的相关参数测试
- Nginx HTTP负载均衡/反向代理的相关参数测试
- Nginx HTTP负载均衡/反向代理的相关参数测试
- Nginx HTTP负载均衡/反向代理的相关参数测试
- NGINX反向代理在测试中的几个应用场景
- Nginx HTTP负载均衡/反向代理的相关参数测试
- nginx 反向代理
- nginx 反向代理
- Nginx 反向代理https
- Nginx 反向代理设置
- nginx反向代理
- linux 环境变量
- 利用Android Studio打开Hierarchy window
- 关于接收到推送下来的通知禁止声音和振动的问题 JPushInterface.setPushNotificationBuilder(1, builder);
- word2010首行缩进、设置页码为第几页共几页、图片完全不显示等问题
- 支付宝刮奖案例
- nginx 反向代理测试
- 学习笔记:dbutils与Spring JdbcTemple的区别
- 1015 计算器的改良
- FineReport做报表常用的命令记录
- mock测试
- HDU 2795 线段树单点更新 好题
- 451. Sort Characters By Frequency
- c++作业6
- 视频播放器