nginx.conf 配置 (反向代理,负载均衡,fastdfs model)

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#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;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location /group1/M00 {
ngx_fastdfs_module;
}

#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;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
listen 81;
server_name localhost;

# charset koi8-r;

# access_log logs/host.access.log main;

location / {
root html81;
index index.html index.htm;
}
}
server {
listen 80;
server_name test.taotao.com;

# charset koi8-r;

# access_log logs/host.access.log main;

location / {
root htmltest;
index index.html index.htm;
}
}
server {
listen 80;
server_name test2.taotao.com;

# charset koi8-r;

# access_log logs/host.access.log main;

location / {
root htmltest2;
index index.html index.htm;
}
}
server {
listen 80;
server_name test3.taotao.com;

# charset koi8-r;

# access_log logs/host.access.log main;

location / {
root htmltest3;
index index.html index.htm;
}
}
upstream tomcats{
server 172.30.101.50:8080 weight=2;
server 172.30.101.50:8081;
}

server {
listen 80;
server_name tomcat.taotao.com;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_pass http://tomcats;
index index.html index.htm;
}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

时间: 2024-07-29 14:05:45

nginx.conf 配置 (反向代理,负载均衡,fastdfs model)的相关文章

编译安装nginx并实现反向代理负载均衡和缓存功能

一.编译安装nginx 1.下载 [[email protected] ~]# wget http://nginx.org/download/nginx-1.10.0.tar.gz 2.解压 [[email protected] ~]# tar xf nginx-1.10.0.tar.gz [[email protected] ~]# cd nginx-1.10.0 3.安装依赖组件 [[email protected] nginx-1.10.0]# yum install pcre-devel

nginx ----> nginx配置/反向代理/负载均衡

1 server { 2 listen 80; 3 server_name localhost; 4 5 location / { 6 #将请求与我们定义的服务器进行映射 7 proxy_pass http://localhost:8080/loginForm; //分号不能少 8 #root html; 9 #index index.html index.htm; 10 } 11 12 error_page 500 502 503 504 /50x.html; 13 location = /5

nginx学习之反向代理负载均衡

nginx是一款很强大的http和反向代理服务器.它的功能非常强大. 并不是一开始就需要负载均衡集群,当网络流量不断增长,单个处理单元无法满足负载请求时,网络应用流量将要出现瓶颈时,负载均衡才会起到作用. 负载均衡与反向代理区别:负载均衡是反向代理的其中一个功能.反向代理服务器还可以缓存静态资源.当用户有请求时,直接返回反向代理服务器上的资源给用户,如果反向代理服务器上没有资源就转发给后端负载均衡服务器. 反向代理一般配置: http { upstream fight {         192

nginx 虚拟主机 反向代理 负载均衡

nginx是一款免费.开源的http服务器,它是由俄罗斯程序设计师开发的,官方测试,nginx能支撑5万的并发量,主要功能有虚拟主机.反向代理和负载均衡等. nginx配置 # 全局块 ... # events块 events { ... } # http块 http { # http全局块 ... # 虚拟主机server块 server { # server全局块 ... # location块 location [PATTERN] { ... } location [PATTERN] {

简单实现Nginx的反向代理+负载均衡

一.引言 上次我们体验了Nginx反向代理的使用,配置是非常简单的,一句配置搞定.这章我们来讲讲在Nginx如何使用反向代理+负载均衡.负载均衡估计程序员都听说过,比如开发一个电商.web端项目什么后期优化需要做负载均衡,不然同时10w用户同时访问,程序就容易相对应的崩溃. 所谓负载均衡,是由多台服务器或服务共同完成一个功能点,从而达到负载均衡的效果.打个比方:用户请求发起一个请求,网站显示的图片量又比较大,如果说这个时候有N个用户同时访问,那么全部的工作量都放在了一台服务器上,指不定什么时候就

Centos7.4 Nginx反向代理+负载均衡配置

Ningx是一款高性能的HTTP和反向代理服务器,配置起来也比较简单. 测试环境: 172.16.65.190 Nginx-反向代理 172.16.65.191 Ningx-Web 172.16.65.192 Nginx-Web 在三台Server安装Nginx: # yum install -y nginx 在172.16.65.190配置Nginx反向代理+负载均衡: # vim /etc/nginx/nginx.conf user nginx; worker_processes auto;

Nginx实现反向代理负载均衡与静态缓存

介绍: Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.在连接高并发的情况下,Nginx是Apache服务器不错的替代品,能够支持高达50000个并发连接数的响应. 实验环境: Hostname IP 系统 规划 n2.preferred 192.168.1.2 Centos 6.5 Web server n3.preferred 192.168.1.3 Centos 6.5 Web server n6.preferred 192.168.1.6

Tomcat反向代理+负载均衡的四种方法配置

环境拓扑 环境说明: IP地址 功能描述 nginx or httpd 172.16.4.100 代理服务器,将用户请求分发到后端的Tomcat服务器实现反向代理和负载均衡 Tomcat-01 172.16.4.101 后端实际提供服务的服务器 Tomcat-02 172.16.4.102 后端实际提供服务的服务器 系统环境都如下所示: [[email protected] ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [[emai

反向代理负载均衡-----nginx

一:集群 1.1:集群的概念 集群是一组相互独立的.通过高速网络互联的计算机,他们构成了一个组,并以单一系统的模式加以管理.一个客户与集群相互作用时,集群像是一个独立的服务器.集群配置是用于提高高可用和可伸缩性.和传统的高性能计算机技术相比,集群技术可以利用各档次的服务器作为节点,系统造价低,可以实现很高的运算速度,完成大运算量的计算,具有较高的响应能力,能够满足当今日益增长的信息服务的需求.而集群技术是一种通用的技术,其目的是为了解决单机运算能力不足.IO能力的不足,提高服务的可靠性.获得规模

反向代理负载均衡之nginx

一.集群 1.1 什么是集群 集群是一组相互独立的.通过高速网络互联的计算机,它们构成了一个组,并以单一系统的模式加以管理.一个客户与集群相互作用时,集群像是一个独立的服务器.集群配置是用于提高可用性和可缩放性. 和传统的高性能计算机技术相比,集群技术可以利用各档次的服务器作为节点,系统造价低,可以实现很高的运算速度,完成大运算量的计算,具有较高的响应能力,能够满足当今日益增长的信息服务的需求. 而集群技术是一种通用的技术,其目的是为了解决单机运算能力的不足.IO能力的不足.提高服务的可靠性.获