#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} 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_timeout 0;
keepalive_timeout 65; #gzip on; #设定负载均衡的服务器列表
#weigth参数表示权值,权值越高被分配到的几率越大
upstream mytest{
server x.x.x.x:8080 weight=1;
server x.x.x.x:8080 weight=1;
} server {
listen 8000;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
#root html;
#index index.html index.htm;
proxy_pass http://mytest;
} #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;
#}
} # 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;
# }
#} }

其中重点是: proxy_pass http://mytest;   mytest是定义了两个服务器,用作负载均衡。

proxy_pass  是转发的路径;

其中后面是否加符号/的区别是:

如果后面加了 /;表示proxy_pass后面的URL就是绝对路径

如果后面没有加/;表示proxy_pass的URL是相对路径,需要加上location 后面匹配的字符串(若有)。

以上是ngnix的Windows版本可用的最基本文件配置!

最新文章

  1. iOS企业分发证书制作
  2. GJM:用C#实现网络爬虫(一) [转载]
  3. 常用正则表达式大全!(例如:匹配中文、匹配html)
  4. ATMEL处理器自带USB CDC的Win7驱动问题
  5. 时间复杂度&空间复杂度
  6. UIWebView用法详解及代码分享
  7. chrome://inspect 移动前端调试方案(Android + Chrome 实现远程调试)
  8. [转载]WEB缓存技术概述
  9. 1.PHP站内搜索 分类: PHP开发实例 2015-07-31 22:48 4人阅读 评论(0) 收藏
  10. fedora安装postgresql
  11. URAL 1260 Nudnik Photographer(递推)
  12. 拆分字符and读取properties文件
  13. 逆向工程vgenerator(一)
  14. Grafana报警--通知渠道配置
  15. iOS逆向开发(3):锁定APP的目标类与函数 | reveal | lldb | debugserver | 远程调试
  16. 学习笔记之tmux
  17. win10 .net framework 3.5无法安装错误代码0x800F081F
  18. mysql集群搭建,主主复制
  19. linux系统分区表修复
  20. 英文词频统计的java实现方法

热门文章

  1. 在JazzyViewPager中调用其它layout布局xml并使用
  2. js中的继承
  3. devtmpfs文件系统创建设备节点
  4. Python 变量类型
  5. jquery图片时钟
  6. [转]CISP(注册信息安全专业人员)认证(12天)
  7. 教你一招 - 如何给nopcommerce增加一个类似admin的area
  8. poj1129 Channel Allocation
  9. 开源框架】Android之史上最全最简单最有用的第三方开源库收集整理,有助于快速开发
  10. 将pdf文件通过itunes直接拖到ipad的ibooks里面