This is the 9th day of my participation in Gwen Challenge

I. Related concepts

  • concept
    • Nginx is a high-performance HTTP and reverse proxy Web server that also provides IMAP/POP3/SMTP services.

    • Nginx is a high-performance web server that can provide web services and mail services. However, we generally use Nginx mainly for Web services, so we can think of Nginx as a high-performance Web server. It can be used as an HTTP server for website publishing processing. It can also be used as a reverse proxy to implement load balancing.

    • Nginx as an HTTP server means that we can directly access static resources on our server through Nginx, so our focus here is on Nginx as a reverse proxy and load balancer.

  • Forward proxy: Proxy is the client (users generally need to set the proxy to access)
  • Reverse proxy: Proxy servers (users generally do not need to set)
  • Load balancing: Requests from clients that cannot be handled by one server are distributed to multiple servers. Reduce the stress on each server.
  • Dynamic and static separation: it separates dynamic resources from static resources and puts them into different servers for parsing to speed up application access.

Two, software installation

  • Nginx download address
  • Install Nginx on Linux

Basic commands

  • sudo nginxStart the Nginx
  • nginx -s stopShutting down Nginx quickly, possibly without saving the information, and quickly terminating the Web service.
  • nginx -s quitShut down Nginx smoothly, save the information, and end the Web service on schedule.
  • nginx -s reloadThe modified configuration takes effect after being reloaded
  • nginx -s quizStop after all user access is complete
  • nginx -s reopenRe-open the log file
  • nginx -vDisplays the version of Nginx
  • nginx -tTest the configuration for errors

4. Configuration files

1. Master configuration filenginx.conf

The/etc/nginx/nginx. Conf or/nginx/conf/nginx. ConfCopy the code

include /etc/nginx/conf.d/*.conf

  • The include file will include all configuration files ending in. Conf from the conf.d directory into the main configuration file.

2. The master configuration file consists of three parts:

Global module

  • Such as:
    • user root; # set system user for nginx service
    • worker_processes 1; # Number of working processes

The events module

  • Handles user/server interactions
  • Like the maximum number of linksworker_connections 1024; Set the maximum number of connections to 1024

HTTP module (emphasis)

1. Internal global modules
2. The upstream module
3. The server module

Reference links:

  • What is Nginx?
  • Basic use of nginx
  • Basic usage of the cloud community Nginx