nginx是一款由俄罗斯人开发的web服务器/反向代理服务器/email服务器/负载均衡器软件,并在一个BSD-like 协议下发行,目前比较流行,最初近适用于Linux平台,目前已有Windows平台版本,优点是资源消耗少、并发处理能力强。
具体的使用的场景参考:Nginx官方参考文档。
具体平台版本见:http://nginx.org/packages/
实验环境:
1,Win7(192.168.84.1)加虚拟机CentOS7(192.168.84.128)
2,Win7下tomcat:apache-tomcat-7.0.68,CentOS7下tomcat:apache-tomcat-7.0.70
3,CentOS7中安装Nginx版本:nginx-1.10.1
CentOS7中安装nginx-1.10.1:
我下载的是源码编译版:nginx-1.10.1.tar.gz,编译安装稳定版需要安装好gcc、gcc-c++、openssl-devel、pcre-devel、zlib-devel,并下载pcre-devel、zlib-devel的源码。
1,解压nginx源码后的目录下,执行:
./configure \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --with-zlib=/home/merrick/zlib-1.2.8 \ --with-pcre=/home/merrick/pcre-8.38 \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_stub_status_module \ --with-http_gzip_static_module \ --http-client-body-temp-path=/var/tmp/nginx/client/ \ --http-proxy-temp-path=/var/tmp/nginx/proxy/ \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
</pre><p></p><pre>
2,编译,安装:
[root@localhost nginx-1.10.1]# make & make install
3,启动,停止:
启动:/usr/local/nginx/sbin/nginx
停止:查到nginx主进程号后(master进程),执行kill -QUIT 主进程号
配置负载均衡:
1,配置/etc/nginx/nginx.conf(参考https://www.nginx.com/resources/admin-guide/load-balancer/):
worker_processes 1; 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; upstream backend{ server 192.168.84.128:8080 weight=5 max_fails=2 fail_timeout=600s; server 192.168.84.1:8080 weight=4 max_fails=2 fail_timeout=600s; } server { listen 192.168.84.128:80; server_name localhost; #charset koi8-r; access_log logs/host.access.log main; location / { proxy_pass http://backend; # root html; # index index.html index.htm; } location /NginxStatus { stub_status on; access_log off; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}
2,启动win7下和centos7下的tomcat
3,在win7下访问centos7的80主页测试几次:
可以看到访问nginx这个代理服务器时会随机转到两个web主页:
相关推荐
Load-Balancing-in-the-Cloud-AWS-NGINX-Plus
docker build -t nginx-load-balancer . 现在,您应该可以使用负载平衡器了。 用法: 您可以使用以下命令运行docker容器: docker run -d -p 8080:80 nginx-load-balancer host_1 host_2 host_3 etc 注意:您应...
作者: Derek DeJonghe Pub Date: 2019 ISBN: 9781491968932 Pages: 175 Language: English Format: PDF
distributed computing Load Balancing
corelb, 在coreinit和 Nginx 上,生成loadbalancer corelb-- 基于coreinit的loadbalancer这是使用 coreinit/etcd作为 Nginx loadbalancer的后备存储的概念证明。运行ETCD_URL=http://192.168.240.1
微服务生态组件之Spring Cloud LoadBalancer详解和源码分析.doc
Nginx入门到实践 Nginx 中间件Nginx入门到实践 Nginx 中间件
load-balancer-由 Vagrant NGINX Tornado MySQL 组合的简单的加载均衡器
because of its capabilities as a load balancer and reverse proxy server for HTTP and other network protocols. The 2019 edition of this popular cookbook provides more than 80 practical recipes to help ...
Part I will focus mostly on the load-balancing aspect and the advanced features around load balancing, as well as some information around HTTP caching. This book will touch on NGINX Plus, the ...
1. 采用nginx最新版编译,包含最新的nginx-http-flv-module,以及基础模块openssl、prce、zlib 2. 整体打包,已配置好nginx.conf的http-flv直播流,以及http web环境。无需任何配置即可使用 3. 自带windows的服务...
nginx-cookbook-recipes-high-performance
nginx带nginx-http-flv模块,包含所有rtmp功能,我自己在windows下编译的,直接可用,用的是最新版的1.19.4版本
在windows 7 64位 环境下使用nginx的nginx-http-flv-module搭建flv视频流播放所有的安装包,参考:https://blog.csdn.net/qq_33071429/article/details/102628008
windows平台nginx编译nginx-http-flv-module,可直接运行,基于nginx-1.17.10编译
07.Nginx Rewrite跳转规则与实践 08.Nginx构建Https加密传输网站(基于IOS苹果要求) 09.Nginx构建动态网站架构lnmp&lnmt 10Nginx+Lua-实战代码灰度发布实战-WAF防火墙 11.Nginx性能优化与压测工具 12.Nginx常见问题 ...
Get sample configurations for the most popular NGINX deployments: load balancing, caching, security, cloud deployment, automation, containers and microservices, high availability, performance tuning,...
nginx+nginx-http-flv,已经编译完成的,配置也已经配置好了,需要的可以下载
Understand the advanced load balancing functionality of Nginx and the newest innovative IO mechanisms Create virtual host configurations effortlessly Discover all the first-party modules: how to ...
windows服务注册: 1. 将压缩包解压到D:\nginx-1.19.3目录下 2. 使用cmd命令打开DOS,并切换到D:\nginx-1.19.3 3. 使用nginxservice.exe install安装 若需要自定义路径,注意在nginxservice.xml文件中修改路径