如何设计高并发应用并利用nginx实现负载均衡与反向代理?
- 内容介绍
- 文章标签
- 相关推荐
本文共计463个文字,预计阅读时间需要2分钟。
Nginx负载均衡是一种网络服务,用于在多个服务器之间分配流量,以提高网站的可用性和性能。它通过将请求分发到多个后端服务器,实现负载的均衡分配。这种方式有助于提升整体系统的稳定性和响应速度。
#《实例:负载均衡》 #$time_iso8601 ISO8601标准格式下的本地时间 2017-08-30T09:16:15+08:00。 #user nobody; worker_processes 1; #工作的子进程数量(通常等于CPU数量或者2倍于CPU) #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; #单个进程最大连接数(最大连接数=连接数*进程数) } my.oschina.net/u/2246410/blog/618798 #netitcast.com 集群名称 #upstream netitcast.com { #server 127.0.0.1:80 weight=2; #服务器配置 #server 127.0.0.1:28080 weight=1; # } server { client_max_body_size 4G; listen 8081; #监听80端口,可以改成其他端口 server_name localhost; #当前服务的域名 #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location ~ .*\.(bmp|swf|css|js)$ { root html; access_log off; expires 0s; } location ~ .*\.(gif|jpg|jpeg|png)$ { root html; expires 0s; } set $uid "-"; if ( $netitcast.com; # proxy_redirect default; # } #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 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; # } #} } nginx-知识点.docx nginx-知识点.docx 高并发设计.pptx 高并发设计.pptx
本文共计463个文字,预计阅读时间需要2分钟。
Nginx负载均衡是一种网络服务,用于在多个服务器之间分配流量,以提高网站的可用性和性能。它通过将请求分发到多个后端服务器,实现负载的均衡分配。这种方式有助于提升整体系统的稳定性和响应速度。
#《实例:负载均衡》 #$time_iso8601 ISO8601标准格式下的本地时间 2017-08-30T09:16:15+08:00。 #user nobody; worker_processes 1; #工作的子进程数量(通常等于CPU数量或者2倍于CPU) #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; #单个进程最大连接数(最大连接数=连接数*进程数) } my.oschina.net/u/2246410/blog/618798 #netitcast.com 集群名称 #upstream netitcast.com { #server 127.0.0.1:80 weight=2; #服务器配置 #server 127.0.0.1:28080 weight=1; # } server { client_max_body_size 4G; listen 8081; #监听80端口,可以改成其他端口 server_name localhost; #当前服务的域名 #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location ~ .*\.(bmp|swf|css|js)$ { root html; access_log off; expires 0s; } location ~ .*\.(gif|jpg|jpeg|png)$ { root html; expires 0s; } set $uid "-"; if ( $netitcast.com; # proxy_redirect default; # } #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 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; # } #} } nginx-知识点.docx nginx-知识点.docx 高并发设计.pptx 高并发设计.pptx

