一、负载均衡,/usr/local/nginx/nginx.conf添加stream便可php
http{ .... }
stream { server { listen 8080 reuseport; proxy_pass netty; } upstream netty { server 192.168.180.68:8080; server 192.168.180.69:8080; } }
二、添加文件服务器,在http中(若是性能不行,可参考http://blog.csdn.net/b_h_l/article/details/17508499)html
server { listen 80; server_name 192.168.180.67;
location / { root /opt/test; index index.php index.html index.htm; autoindex on; autoindex_exact_size off; autoindex_localtime on; } }
三、虚拟目录()nginx
server { listen 80; server_name localhost; location / { root /404.html; index index.php index.html index.htm; } location /recfile { alias /home/netrec/; index index.php index.html index.htm; autoindex on; autoindex_exact_size off; autoindex_localtime on; } location /test { proxy_pass http://ip:port; } }
nginx配置下有两个指定目录的执行,root和aliasbash
location /img//var/www/p_w_picpath/
location /img//var/www/p_w_picpath
alias是一个目录别名的定义,root则是最上层目录的定义。服务器
还有一个重要的区别是alias后面必需要用“/”结束,不然会找不到文件的。。。而root则无关紧要~~负载均衡
四、refer防盗链ide
https://help.aliyun.com/knowledge_detail/6708458.html?pos=2post
五、重定向到某个地址性能
server { listen 9000; server_name www.abc.com; rewrite ^/(.*)$ http://180.133.180.198:9002/$1 permanent; }