首页 > nginxnginx实例操作负载均衡

nginx.conf设置

upstream www.ngmore.com {
#ip_hash;
server 127.0.0.1:81;
server 127.0.0.1:82;
#queue 5 timeout=3;
}

 

www.ngmore.com配置

server {
listen 88;
server_name default_server ;
# access_log logs/www.ngmore.access.log main;
location / {
proxy_pass http://www.ngmore.com ;
}
}

127.0.0.1:81配置

server
{
listen 81;
#listen [::]:80;
server_name default_server;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/more1;

include none.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log off;
}

127.0.0.1:82配置

server
{
listen 82;
#listen [::]:80;
server_name default_server;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/more1;

include none.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log off;
}