码迷,mamicode.com
首页 > 其他好文 > 详细

部署分布式存储系统FastDFS(续一)

时间:2015-09-08 12:46:42      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

因字数限制,新开文章

第九天

今天设置nginx代理,代理存储服务的http访问。

在没有代理前,我们上传了图片,需要使用group中的任一storage server进行访问,如果是多group,很麻烦。

新增一台虚拟机,部署nginx环境,参考网上教程。

nginx配置文件如下(包含了简单的防盗链功能):

user www-data;

worker_processes 4;

pid /run/nginx.pid;


events {

worker_connections 768;

# multi_accept on;

}


http {

include mime.types;

default_type application/octet-stream;

server_names_hash_bucket_size 128;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 300m;

sendfile on;

tcp_nopush on;

keepalive_timeout 120;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types text/plain applicatin/x-javascript text/css application/xml;

gzip_vary on;

gzip_disable "MSIE[1-6]."

proxy_redirect off;

#当后端单台web服务器上配置有多个虚拟主机时,需要使用该Header来区分反向代理哪个主机名

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_connect_timeout 90;

proxy_send_timeout 90;

proxy_read_timeout 90;

proxy_buffer_size 16k;

proxy_buffers 4 64k;

proxy_busy_buffers_size 128k;

proxy_temp_file_write_size 128k;

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 /var/log/nginx/access.log main;

proxy_cache_path /var/cache/nginx/proxy_cache levels=1:2 keys_zone=http-cache:500m max_size=10g inactive=30d;

proxy_temp_path /var/cache/nginx/proxy_cache/tmp;

upstream group1 {

server 192.168.127.135:80;

server 192.168.127.136:80;

}

server {

listen 80;

server_name www.test.com;

root /usr/share/nginx/html;

        index index.html index.htm;


location / {

try_files $uri $uri/ =404;


}

location /group1/M00 {

valid_referers none blocked server_names *.test.com;

if ($invalid_referer){

rewrite ^/ http://www.test.com/fangdao.html;

#return 403;

}

proxy_next_upstream http_502 http_504 error timeout invalid_header;

proxy_cache http-cache;

proxy_cache_valid 200 304 12h;

proxy_cache_key $uri$is_args$args;

proxy_pass http://group1;

expires 30d;

}

}

}


部署分布式存储系统FastDFS(续一)

标签:

原文地址:http://my.oschina.net/longfirst/blog/502680

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!