Implementation of Nginx configuration of local image server

Implementation of Nginx configuration of local image server

1. Introduction to Nginx

Nginx is a reverse proxy server.

First, let’s take a look at what a proxy server is. A proxy server generally refers to a machine within a local area network that sends requests to a server on the Internet through a proxy service. A proxy server generally acts on the client. For example, GoAgent, FQ artifact.

img

A complete proxy request process is as follows: the client first establishes a connection with the proxy server, and then requests to establish a connection with the target server or obtain the specified resources of the target server according to the proxy protocol used by the proxy server. A web proxy server is an intermediary entity in a network. The proxy sits between the web client and the web server, acting as a "middleman".
An HTTP proxy server is both a web server and a web client.

A proxy server is another server between the client and the Web server. With it, the browser does not go directly to the Web server to retrieve the web page, but sends a request to the proxy server. The signal will first be sent to the proxy server, which will retrieve the information the browser needs and transmit it to your browser.

A forward proxy is a server located between the client and the original server. In order to obtain content from the original server, the client sends a request to the proxy and specifies the target (the original server). The proxy then forwards the request to the original server and returns the obtained content to the client. The client must perform some special settings to use a forward proxy.

Reverse proxy server: Receives client requests on the server side, distributes the requests to specific servers for processing, and then feeds back the server's response results to the client. Nginx is one of the reverse proxy server software.
Nginx: Nginx ("engine x") is a high-performance HTTP and reverse proxy server written by Russian Igor Sysoev. It is also an IMAP/POP3/SMTP proxy server, that is, Nginx itself can host websites, perform HTTP service processing, and can also be used as a reverse proxy server.

The forward proxy client must set up a forward proxy server. Of course, the prerequisite is to know the IP address of the forward proxy server and the port of the proxy program.
A reverse proxy is the opposite of a forward proxy. To the client, the proxy server looks like the original server, and the client does not need to perform any special settings. The client sends a normal request to the content in the reverse proxy's namespace, and the reverse proxy then determines which original server to forward the request to and returns the obtained content to the client.

2. Image Server Construction

After installing nginx locally, we can access it through the port. The default port is port 80. Since it conflicts with the local port 80, I changed it to 8089.

image-20211210195430120

At this point we have successfully started nginx, and then under the nginx directory, add the image path we need to configure, as follows:

		#Add image code location ~ .*\.(gif|jpg|jpeg|png)$ {  
      expires 24h;  
      root H:/radar/;#Specify the image storage path access_log H:/radar/log;#Image path proxy_store on;  
      proxy_store_access user:rw group:rw all:rw;  
      proxy_temp_path H:/radar/;#image path proxy_redirect off;  
      
      proxy_set_header Host 127.0.0.1;  
      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 http://127.0.0.1:8089; #Proxy access address}  
      }    

According to the above configuration, find the path we need. Then restart the service, and you can see the pictures we configured. As shown in the figure below

image-20211210195955312

At this point a simple nginx image server has been built. This is the end of this article about how to configure a local image server with Nginx. For more information about Nginx local image server, please search for previous articles on 123WORDPRESS.COM or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to use nginx to access local static resources on Linux server
  • Explain the simple method of setting up local browser cache in Nginx server
  • Related settings of browser local cache and virtual machine in Nginx server

<<:  The difference between z-index: 0 and z-index: auto in CSS

>>:  About the pitfall record of Vue3 transition animation

Recommend

Several mistakes that JavaScript beginners often make

Table of contents Preface Confusing undefined and...

Some experience sharing on enabling HTTPS

As the domestic network environment continues to ...

How to run .sh files in Linux system

There are two ways to run .sh files in Linux syst...

Stealing data using CSS in Firefox

0x00 Introduction A few months ago, I found a vul...

Basic operation tutorial of files and permissions in centos

Preface Before we begin, we should briefly unders...

The difference between docker run and start

The difference between run and start in docker Do...

A brief analysis of controlled and uncontrolled components in React

Table of contents Uncontrolled components Control...

11 ways to remove duplicates from js arrays

In actual work or interviews, we often encounter ...

Analysis of the advantages of path.join() in Node.js

You might be wondering why you should use the pat...

A practical record of checking and processing duplicate MySQL records on site

Table of contents Preface analyze Data Total Repe...

Linux command line quick tips: How to locate a file

We all have files stored on our computers -- dire...

Problems with using multiple single quotes and triple quotes in MySQL concat

When dynamically concatenating strings, we often ...

Example of MySQL slow query

Introduction By enabling the slow query log, MySQ...

JavaScript Document Object Model DOM

Table of contents 1. JavaScript can change all HT...

Vue implements adding watermark effect to the page

Recently, when I was working on a project, I was ...