In recent days, has been learning Nginx in Windows platform use, in order to find a number of images distributed storage and there is a relatively simple storage scheme nginx is a kind of, also found a MongoDB gridfs these two options I still prefer, after today's struggle, Finally the Nginx do picture distributed storage of this scheme set up the environment, GRIDFS in the follow-up study I will also record the construction process, please look forward to it.
Cut the crap. Windows+nginx+iis how to build a distributed storage structure.
1. Structure overview
Logical Structure:
Figure 1
, this is the ideal erection, I this simulation of the structure of the logic is such that my own, in fact, I do not have so many computers, I can only use virtual machine virtual out of a Windows 2003 system
Is the structure of my own actual erection:
Figure 2
Let me elaborate:
Required Resources:
A. A test site, very simple, there is an upload image, as well as browse the picture is good, a page enough
B. Nginx Proxy Server, I will use the Nginx Proxy server is also used to store pictures, so it is also image server number 1th
C. Image server to share the picture of number 1th
D. The second picture, I actually set up the structure, the machine is not enough, so my own laptop will install the following configuration:
A) test site www.demo.com
b) Nginx Server Proxy
c) Image Server No. 1th
The virtual machine is used to make the picture server number 2nd.
Implementation principle
1. The user has 2 upload the picture way:
A) The first type of Http://img.nginxtest.com/s1/upload.aspx
b) The second type of Http://img.nginxtest.com/S2/upload.aspx
After the request is sent to the Nginx server, it is forwarded to a different 2 image server according to the S1,S2 in the URL.
The request with/S1/is sent to the 1th image server, which contains the/s2/to the server number 2nd.
2. The structure of future picture preservation is as follows
A) photo 1th will save the picture in/s1/... Directory under
b) Similarly, server 2nd will be saved in/s2/... Directory under
c) I here picture upload after image saved URL structure:
No. 1th Server: http://img.nginxtest.com/S1/photo/1234/123456/product/_2013113144712237_s.jpg
II. On server No. 2nd: http://img.nginxtest.com/S2/photo/1234/123456/product/_2013113145230921_s.jpg
d) Request
2. Picture Server Configuration
Step by step to configure the process, the first to configure 2 image server, to receive the user uploaded images and saved locally. Here are the rules, 2 nginx proxy server is my own notebook named a machine (ip:192.168.21.1), virtual machine named B Machine (ip:192.168.21.128), for the following abbreviation
A) A machine configuration Picture server: Domain name: img.nginxtest.com Port 801
b) A number machine configuration Picture Server installation Nginx Port use 80
c) A machine configuration test website domain name www.demo.com Port 8012
d) Virtual machine configuration Picture Server domain name img.s2.com port 80
e) Modify the Hosts file
f) Configure Nginx to find the nginx.conf file
The red box implements the Nginx processing URL splitter, which distributes the request according to/s1/in the URL,/s2/
Ok~, the above is the main configuration process, there are some can not speak language, their own limited language skills AH (sweat ~ ~)
Provide some references
1. Short and practical distributed picture Storage program Thank the blogger for his ideas.
2. nginx configuration file Description this should be seen at least, otherwise the novice will not configure
Http://blog.sina.com.cn/s/blog_75a555e40101fie9.html
Windows+nginx+iis doing picture distributed storage detailed steps