大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#user nobody;
worker_processes1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections1024;
}
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;
#tcp_nopush on;
#keepalive_timeout0;
keepalive_timeout65;
#gzip on;
upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
#1.down 表示单前的server暂时不参与负载
#2.weight 默认为1.weight越大,负载的权重就越大。
#3.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
#server192.168.1.116 down;
#server192.168.1.116 backup;
server192.168.1.128:8080 weight=1;
server192.168.1.194:8080 weight=2;
}
server {
listen80; #这里是外网公布的访问的端口
server_name122.122.122.122; #这里是外网公布的访问的公网ip 、或是域名
#charset koi8-r;
#access_log logs/host.access.log main;
location/ {
proxy_pass http://mysvr; #跟载均衡服务器的upstream对应
proxy_connect_timeout 5s; #这里代表其中一台服务器宕机之后把访问转向另外一台服务器
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#禁用缓存
proxy_buffering off;
}
#error_page404 /404.html;
# redirect server error pages to thestatic page /50x.html
#
error_page500 502 503 504 /50x.html;
location= /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on127.0.0.1:80
#
#location~ .php$ {
# proxy_pass http://127.0.0.1; #}
# pass the PHP scripts to FastCGI server listening on127.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;
#}
}
# anothervirtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location/ {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen443 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相关命令:1) 启动Nginx:start nginx
创新互联是一家专注于网站制作、成都网站设计与策划设计,于田网站建设哪家好?创新互联做网站,专注于网站建设10余年,网设计领域的专业建站公司;建站业务涵盖:于田等地区。于田做网站价格咨询:189820811082) 停止Nginx:nginx -s stop
3) 修改配置后重启:nginx -s reload