location / {
root html;
index index.html index.htm default.aspx;
proxy_pass ;
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 ;
#}
# 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.conf 配置
不用害怕,修改的地方很少。
(1)worker_processes 4;#启动的线程数 一般为你代理服务器的内核数
(2)在“HTTP”括弧中配置服务器群的网站发布的ip地址和端口号
upstream linuxidc.com{
server x.x.x.x:8091; #服务器A
server x.x.x.x:8092; #服务器B
}
(3)配置代理服务器的地址,即Nginx安装的服务器地址、监听端口、默认地址
server {
listen 8090; #监听端口
server_name localhost; #服务器Ip地址
#charset koi8-r;
#access_log logs/host.access.log main;