nginx做为web容器部署静态资源以及做负载均衡反向代理实现
需求:
#user nobody;
worker_processes ;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
charset utf-;
#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 ;
keepalive_timeout ;
client_max_body_size 64m;
client_header_buffer_size 16k;
client_header_timeout ;
client_body_timeout ;
open_file_cache max= inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses ;
underscores_in_headers on;
#gzip on;
gzip on; gzip_min_length 1k;
gzip_buffers 16k;
gzip_http_version 1.0;
gzip_comp_level ;
gzip_proxied any;
gzip_types text/plain application/x-javascript application/javascript text/css application/json text/javascript image/jpeg image/jpg image/gif image/png application/x-bmp application/x-shockwave-flash application/xml+rss;
gzip_vary on;
gzip_disable "MSIE [1-6]\."; fastcgi_connect_timeout ;
fastcgi_send_timeout ;
fastcgi_read_timeout ;
fastcgi_buffer_size 64k;
fastcgi_buffers 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
upstream cfsCluster{
ip_hash;
server 192.168.249.144:;
}
server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
add_header backendIp $upstream_addr;
root C:\Users\lidedong\Desktop\dist;
index index.html;
}
location /backend {
proxy_pass http://cfsCluster;
add_header backendIp $upstream_addr;
add_header backendCode $upstream_status;
proxy_set_header X-Real_Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
}
} }
常用的代理配置粘上:
# proxy.conf
# proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header Remote_Addr $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection "";
proxy_set_header Cookie $http_cookie;
#proxy_set_header x_enb_token $x_enb_token;
#proxy_set_header x_enb_userid $x_enb_userid;
#proxy_set_header x_enb_ctime $x_enb_ctime;
#proxy_set_header x_enb_clientid $x_enb_clientid;
client_max_body_size 64m;
client_body_buffer_size 128k;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
proxy_buffers 8k;
proxy_buffer_size 16k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_headers_hash_max_size ;
proxy_ignore_client_abort on;
nginx做为web容器部署静态资源以及做负载均衡反向代理实现的更多相关文章
- Nginx服务器部署 负载均衡 反向代理
Nginx服务器部署负载均衡反向代理 LVS Nginx HAProxy的优缺点 三种负载均衡器的优缺点说明如下: LVS的优点: 1.抗负载能力强.工作在第4层仅作分发之用,没有流量的产生,这个特点 ...
- Nginx HTTP负载均衡/反向代理的相关参数测试
原文地址:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/03/15/1984976.html 测试目的 (1)弄清楚HTTP Upstr ...
- 激活web容器对静态资源的默认servlet处理
在某些servlet的url匹配模式使用/时会拦截一些静态的资源的请求导致无法正确访问,可以采取web容器默认的servlet来处理,当然那些mvc一般也都提供了处理的方法,用何种方式可以自行决定,这 ...
- 架构之Nginx(负载均衡/反向代理)
Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器 ,也是一个 IMAP/POP3/SMTP 代理 服务器 . Nginx 是由 Igor Sys ...
- nginx域名转发 负载均衡 反向代理
公司有三台机器在机房,因为IP不够用,肯定要分出来,所以要建立单IP 多域名的反向代理, 就是当请求www.abc.com 跳转到本机, 请求www.bbc.com 跳转到192.168.0.35 机 ...
- nginx 负载均衡 反向代理
nginx 通过方向代理实现负载均衡,负载均衡是大流量网站要做的措施,单从字面上的意思来理解为N台服务器平均分担负载,不会因为某一台服务器负载高宕机而影响用户访问网站,负载均衡至少需要三台服务器, 既 ...
- Nginx负载均衡反向代理 后端Nginx获取客户端真实IP
Nginx 反向代理后,后端Nginx服务器无法正常获取客户端的真实IP nginx通过http_realip_module模块来实现的这需要重新编译,如果提前编译好了就无需重新编译了1,重新编译ng ...
- nginx负载均衡(反向代理)
6,安装nginx 6.1 依赖库安装 要安装在root根目录里,不要装在虚拟环境里面 yum install gcc-c++ pcre pcre-devel zlib zlib-devel ope ...
- keepalived + nginx(负载均衡反向代理HTTP,https) + tomcat(HTTP,https)
基本架构: nginx(192.168.116.198) client --->keepalived(116.200) ------> tomcat (192.16 ...
随机推荐
- Flutter安装
下载右边的安装包以获取最新版本 stable 的 Flutter SDK 将压缩包解压,然后把其中的 flutter 目录整个放在你预想的 Flutter SDK 安装目录中(比如 C:\src\fl ...
- pwn学习日记Day13 《程序员的自我修养》读书笔记
重定位就是把程序的逻辑地址空间变换成内存中的实际物理地址空间的过程.它是实现多道程序在内存中同时运行的基础.重定位有两种,分别是动态重定位与静态重定位. 静态重定位:即在程序装入内存的过程中完成,是指 ...
- Linux设备驱动程序 之 后备高速缓存
设备驱动程序常常会反复的分配很多相同大小的内存块:内核实现了后备高速缓存来对此进行支持,以反复的使用这些相同的内存块: 创建 Linux内核的高速缓存管理有时被称为“slab分配器”:因此,相关函数和 ...
- intellj idea 常用快捷键
1.command+shift+a 查找操作2.command+e 查找历史打开的文件3.command+n 查找类4.command+shift+n 查找文件
- arcgis python 把多个MXD批量导出一个PDF
# -*- coding: cp936 -*- import arcpy, os, string #Read input parameters from script tool mxdList = s ...
- 009-DNS域名解析系统
一.概述 DNS是域名系统(DomainNameSystem)的缩写,该系统用于命名组织到域层次结构中的计算机和网络服务.域名是由圆点分开一串单词或缩写组成的,每一个域名都对应一个惟一的IP地址,在I ...
- strace调试跟踪程序运行状态
查看进程调用和执行状态 : strace -f -F -o debug.log -p PID(某个进程ID) 参考资料: http://www.itshouce.com.cn/linu ...
- CISCN 2019 writeup
划水做了两个pwn和两个逆向...... 二进制题目备份 Re easyGO Go语言,输入有Please字样,ida搜索sequence of bytes搜please的hex值找到字符串变量,交叉 ...
- 图解 HTTP 笔记(八)——常见 Web 攻击技术
本章主要讲解 HTTP 通信过程中的一些常见 Web 攻击技术 一.跨站脚本攻击 跨站脚本攻击(Cross-Site Scripting, XSS)是指通过存在安全漏洞的 Web 网站注册用户的浏览器 ...
- SpringBoot: 18.使用Scheduled 定时任务器(转)
Scheduled 定时任务器:是 Spring3.0 以后自带的一个定时任务器. 1.在pom.xml文件中添加Scheduled依赖 <!-- 添加spring定时任务 Scheduled ...