nginx.conf

1.反向代理 

    server {
        listen       80;
        server_name  www.domainname.com
        location / {
		    proxy_pass  http://www.domainname.com:8080;
		    index  index.html index.htm;
        }
    }

2.負載均衡

    upstream backserver { 
       server 127.0.0.1:8080 weight=1;  #weight 指定權重
       server 127.0.0.1:8081 weight=2; 
    } 

    server {
        listen       80;
        server_name  www.domainname.com;
        location / {
		  proxy_pass  http://backserver;
		  index  index.html index.htm;
        }
    }

    配置宕機輪訓配置規則
    server {
        listen       80;
        server_name  www.domainname.com;
        location / {
          proxy_pass  http://backserver;
          index  index.html index.htm;
          proxy_connect_timeout 1;
          proxy_send_timeout 1;
          proxy_read_timeout 1;
        }
    }
   

3.解決網站跨域

server {
        listen       80;
        server_name  www.domainname.com;
        location /A {
            proxy_pass  http://a.domainname.com;
            index  index.html index.htm;
        }
        location /B {
            proxy_pass  http://b..domainname.com;
            index  index.html index.htm;
        }
}

4.防盜鏈

location ~ .*\.(jpg|jpeg|JPG|png|gif|icon)$ {
        valid_referers blocked http://www.domainname.com www.domainname.com;
        if ($invalid_referer) {
            return 403;
        }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章