nginx負載均衡&文件服務器配置&虛擬目錄&代理&refer防盜鏈

一、負載均衡,/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和alias指令的區別

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;
    }
相關文章
相關標籤/搜索