02-Nginx反向代理和负载均衡
来源:互联网 发布:淘宝店家一元拍 编辑:程序博客网 时间:2024/05/22 06:05
正向代理
表示确定服务器的地址,比如翻墙。
反向代理
表示不确定服务器地址,比如服务器集群
负载均衡
一台服务器压力比较大,会奔溃,通过代理服务器管理集群分担压力。
#声明用户为nobodyuser nobody;#开启nginx工作进程数,一般为1#可以通过ps -ef | grep nginx 查看到有4个工作进程worker_processes 4;#设置并发数events{ #设置最大并发数 worker_connections 1024;}http{ #设置待负载均衡服务器列表 upstream mypro { #百度 server 119.75.213.61; #京东 server 124.192.136.131; #万网 server 199.59.242.150; } #nginx服务器 server{ #监听网站端口 listen 8080; #nginx根目录 location / { #做负载均衡选择哪个服务器列表 proxy_pass http://mypro; } }}~
#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 8080; 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; } # 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; #} } # 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; # } #} include servers/*;}
阅读全文
0 0
- 02-Nginx反向代理和负载均衡
- nginx 负载均衡和反向代理
- Nginx实现反向代理和负载均衡
- Linux -- Nginx 负载均衡和反向代理
- nginx之反向代理和负载均衡
- Nginx反向代理和负载均衡
- Nginx反向代理和负载均衡
- nginx 反向代理和负载均衡
- Nginx的反向代理 和 负载均衡
- Linux -- Nginx 负载均衡和反向代理
- Nginx反向代理和负载均衡部署
- Nginx反向代理和负载均衡
- Nginx反向代理和负载均衡
- nginx反向代理和负载均衡配置
- (8)nginx:反向代理和负载均衡
- Nginx实现负载均衡和反向代理
- Nginx的负载均衡和反向代理
- nginx反向代理和负载均衡
- 机器学习与线性回归
- UPCOJ 4201
- TexturePacker免费申请注册码
- 二维关联数组转字符串
- HashMap相关问题
- 02-Nginx反向代理和负载均衡
- printf()格式化输出详解
- PAT甲级1002-写出这个数
- 递归显示文件夹下的所有目录(带绝对路径):并且解决中文乱码问题
- 使用BBR一键脚本为你的CentOS/Debian/Ubuntu系统加速
- 【问题】windows 10下报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES
- 跨域请求 禁用网络安全
- CSS总结——1
- 漂亮的php验证码类