window server deploy picture server through nginx

Environment background: you need to access the picture information through the domain name on the Internet.

Idea: use nginx to deploy image server.

1. First download the latest stable version of nginx on the nginx official website(

2. After downloading, unzip and modify the configuration file of nginx (conf---nginx.conf in the unzip folder)

server {
        listen       8887;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index  index.html index.htm;

The modified part is the port in the server, and then the main part is to configure the image server:

location ~ .*\.(gif|jpg|jpeg|png)$ {  
        expires 24h;  
            root E:/image/image/;#Specify image storage path  
            access_log E:/image/img_nginx.log;# Log path  
            proxy_store on;  
            proxy_store_access user:rw group:rw all:rw;  
            proxy_temp_path         E:/image/image/;#Picture path  
            proxy_redirect          off;  
            proxy_set_header        Host;  
            proxy_set_header        X-Real-IP $remote_addr;  
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;  
            client_max_body_size    10m;  
            client_body_buffer_size 1280k;  
            proxy_connect_timeout   900;  
            proxy_send_timeout      900;  
            proxy_read_timeout      900;  
            proxy_buffer_size       40k;  
            proxy_buffers           40 320k;  
            proxy_busy_buffers_size 640k;  
            proxy_temp_file_write_size 640k;  
            if ( !-e $request_filename)  
                 proxy_pass; agent access address  

The root path above depends on your own changes.

3. Place an image in the root path defined by yourself, such as 1.jpg

4. Start nginx and run nginx.exe in the nginx file directory

4. Visit http://localhost:8887/1.jpg in the browser

5. Complete the deployment.

In addition, some nginx shortcut commands under the window server are attached:

1. Shut down the server, create a new TXT document, copy the following code, in which the front is the folder path of nginx. After copying, change the suffix of txt to bat, and the shortcut will be finished. If you want to shut down later, run the bat file directly.

D:\nginx-1.14.0\nginx-1.14.0\nginx.exe -s stop

2. Restart the nginx server. The principle is the same as the above. Just replace the above stop with reload.

Tags: Nginx

Posted on Mon, 06 Jan 2020 04:22:51 -0800 by seventheyejosh