在nginx.conf文件中的FASTDFS配置以下:
javascript
文件1:nginx.confcss
user root; worker_processes 24; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; worker_rlimit_nofile 30000; events { use epoll; worker_connections 30000; } http { include mime.types; default_type application/octet-stream; server_tokens off; #關閉版本顯示 log_format main '[$time_local] -- $remote_addr -- $remote_port "$request_method $request_uri $server_protocol" $status "$upstream_response_time" -- "$request_time" -- "$host $server_addr $server_port $server_name" - "$http_referer"'; access_log logs/access.log main; upstream game_server { server 192.168.11.11:8012; server 192.168.11.12:8012; } upstream gamefw_server { server 192.168.11.11:8112; server 192.168.11.12:8112; } ####################fast dfs upstream begin############################# upstream group1_server { server 192.168.11.206:9000 max_fails=1 fail_timeout=30s; } ####################fast dfs upstream end ############################# sendfile on; tcp_nopush on; keepalive_timeout 300; gzip on; gzip_buffers 4 16k; gzip_comp_level 6; gzip_min_length 1000; gzip_types application/x-javascript application/xml text/css text/plain; gzip_vary on; #client_body_temp on; #client_body_buffer_size 128k; client_header_buffer_size 8k; large_client_header_buffers 4 16k; client_header_timeout 120s; client_body_timeout 120s; client_max_body_size 100M; client_body_buffer_size 512k; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_cache_key "$scheme$host$request_uri"; proxy_cache_path /home/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g; include nginx_v.conf; }
文件2:nginx_v.confhtml
server { listen 9000; server_name lili*.game.cn; client_max_body_size 300m; charset utf-8; proxy_next_upstream http_502 http_504 http_500 http_404 error timeout invalid_header; #若是須要開啓HTTP強制跳轉成https請開啓下面的配置,前期能夠先不放開,等運行穩定後再開啓 #rewrite ^(.*)$ https://$host:443$1 permanent; #access_log logs/host.access.log main; # if ($request_uri ~ ^(/user/m/login|/user/m/loginkey|/user/m/login/checkkey|/m/login|/sys/m/login|/views/getpass1.html|/views/register.html|/user/m/user/findpasssave)(.*)) { # return 301 https://$host:443$request_uri; # } # if ($request_uri ~ ^(/mhs/NetSyEdu/watchvideo)(.*)) { # return 301 https://$host$request_uri; # } # if ($request_uri ~ ^(/mhs/NetMfEdu/watchvideo)(.*)) { # return 301 https://$host$request_uri; # } # if ($request_uri ~ ^(/mhs/NetSyEdu/viewdocument)(.*)) { # return 301 https://$host$request_uri; # } # if ($request_uri ~ ^(/mhs/NetMfEdu/viewdocument)(.*)) { #return 301 https://$host$request_uri; # } # if ($request_uri ~ ^(/mhs/NetSyEdu/toTest)(.*)) { # return 301 https://$host$request_uri; # } # if ($request_uri ~ ^(/mhs/NetMfEdu/toTest)(.*)) { # return 301 https://$host$request_uri; # } location /nginxstatus { # stub_status on; access_log off; #加入訪問限制 #allow 定時任務sysip; #allow 運維任務sysip; #allow 自動發佈系統ip; #deny all; #allow 192.168.200.202; # allow 192.168.200.203; # allow 192.168.200.201; # deny all; } location / { proxy_set_header Host $host:$server_port; # proxy_redirect http:// https://; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://game_server/; client_max_body_size 20m; } location /risdz { proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://gamefw_server/; client_max_body_size 20m; } ##############fastdfs config begin################################## location /group1/M00 { root /data00/data; ngx_fastdfs_module; } location /group1/M01 { root /data01/data; ngx_fastdfs_module; } location /group1/M02 { root /data02/data; ngx_fastdfs_module; } location /group1/M03 { root /data03/data; ngx_fastdfs_module; } ##############fastdfs config begin################################## } #HTTPS server server { listen 443 ssl; server_name localhost; #ssl ; ssl_certificate ../ssl/server.crt; ssl_certificate_key ../ssl/server.key; ssl_session_timeout 5m; #ssl_protocols SSLv2 SSLv3 TLSv1; #ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "LOW !3DES !MD5 !RC4 !***"; location / { proxy_set_header X-Forwarded-For $remote_addr; proxy_redirect http:// https://; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://game_server; } ##############fastdfs config begin################################## location /group1/M00 { root /data00/data; ngx_fastdfs_module; } location /group1/M01 { root /data01/data; ngx_fastdfs_module; } location /group1/M02 { root /data02/data; ngx_fastdfs_module; } location /group1/M03 { root /data03/data; ngx_fastdfs_module; } ##############fastdfs config begin################################## }
查看圖片的方法:java
有個圖片ra0KzlviQSiADCkCAGHkfkT9QK8875.JPG,在/data00/data/23/4D 目錄中,python
根據nginx.conf文件中的配置能夠看出FASTDFS 服務器和端口是192.168.11.206:9000nginx
在nginx_v.conf文件中的配置能夠看出FASTDFS 服務器有4個存儲目錄,服務器
圖片文件存在/data00-3/data 目錄中。session
在查詢的時候,須要用別名目錄查詢,即:/group1/M0-3app
查看連接以下:運維
域名查看:https://lili*.game.cn:443/group1/M00/23/4D/ra0KzlviQRiAOspeAAMiFz_m_wA663.jpg
服務器查看:192.168.11.206:9000/group1/M00/23/4D/ra0KzlviQRiAOspeAAMiFz_m_wA663.jpg