Nginx集群模塊
阿新 • • 發佈:2017-06-27
oca ocs p s ref con document sta 配置 red
ngx_http_upstream_module模塊是定義一組服務器的,可以是proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, 和 memcached_pass 指令。
下面寫一個考試系統的集群Nginx+Tomcat
新建Nginx的配置文件
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/exam_nginx.conf
編輯exam_nginx.conf,內容如下:
server { listen 80; server_name exam.windy.com; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { proxy_pass http://exam.windy.com; } #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/usr/share/nginx/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_pass127.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 exam.windy.com { server 192.168.52.130:8081; server 192.168.52.130:8080; }
Nginx集群模塊