请各位大虾高手帮助,nginx的负载均衡配置,不需要安装tomat等软件的。
做web的负载均衡,用nginx.conf配置文件弄的。
求解!
谢谢!
参考:阿里云负载均衡怎么配置 https://yq.aliyun.com/articles/697165
# 配置 /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 10240;
}
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;
client_max_body_size 10m;
gzip on;
#gzip_comp_level 4;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript application/javascript text/javascript application/json;
#gzip_disable "MSIE [1-6]\.";
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
server_tokens off;
proxy_cache_path cache levels=1:2 keys_zone=redmine:100m inactive=2m max_size=1g;
server {
listen 3000;
server_name localhost;
#charset utf-8;
#access_log logs/host.access.log main;
access_log off;
location / {
proxy_cache redmine;
proxy_cache_valid 200 304 1m;
proxy_pass http://backend;
root html;
index index.html index.htm;
rewrite /download http://g.cn permanent;
}
#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;
#}
}
upstream backend {
ip_hash;
server 127.0.0.1:3001 weight=4;
server 127.0.0.1:3002 weight=6;
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。