The concurrent ability of Nginx in the same type of web server is relatively good, so it is favored by many enterprises. The famous users of Nginx website in China include Tencent, Taobao, Baidu, JINGdong, Sina, netease and so on. Nginx is one of the essential skills for web server operation and maintenance personnel. Here are some common Nginx interview questions for your reference:
1. Please explain what Nginx is.
Nginx is a Web server and reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols.
2. Please list some features of Nginx.
Nginx server features include:
Reverse proxy /L7 Load balancer
Embedded Perl interpreter
Dynamic binary upgrade
Can be used to rewrite urls with very good PCRE support
3. List the differences between Nginx and Apache.
4. Explain how Nginx handles HTTP requests.
Nginx uses the reactor pattern. The main event loop waits for the operating system to signal that it is ready for an event so that data can be read from the socket, read into the buffer in this instance, and processed. A single thread can provide tens of thousands of concurrent connections.
In Nginx, how to use undefined server names to prevent requests from being processed?
Simply define the server requesting removal as:
Server { listen 80; Server_name ""; return 444; }Copy the code
Here, the server name is left as an empty string, which will match the request without the “host” header field, and a special Nginx non-standard code 444 is returned, terminating the connection.
6. What are the advantages of using a reverse proxy server?
A reverse proxy server can hide the existence and features of the source server. It acts as an intermediate layer between the Internet cloud and the Web server. This is great for security, especially if you use web hosting services.
7. List the best uses of Nginx server.
The best use of the Nginx server is to deploy dynamic HTTP content on the network, using SCGI, WSGI application servers, and FastCGI handlers for scripts. It also acts as a load balancer.
8. What are the Master and Worker processes on the Nginx server?
Master process: reads and evaluates configuration and maintenance
Worker process: Handles requests
9, please explain how you can start Nginx from a different port than 80.
To enable Nginx through a different port, you must go to /etc/nginx/sites-enabled. If this is the default file, then you must open a file named “default”. Edit the file and place it on the port you want:
Like server { listen 81; }
Copy the code
10, please explain if it is possible to replace Nginx error with error 502, 503?
502 = Wrong gateway
503 = Server overload
Possibly, but you can make sure that fastcgi_intercept_errors is set to ON and use the error page directive.
Location / {fastcgi_pass 127.0.01:9001; fastcgi_intercept_errors on; error_page 502 =503/error_page.html; #... }Copy the code
In Nginx, explain how to keep double slashes in URLS.
To keep the double slash in the URL, you must use merge_slashes_off;
Grammar: merge_slashes [on/off]
Default value: merge_slashes on
Environment: HTTP, server
12. Explain what ngx_HTTP_upstream_module does.
Ngx_http_upstream_module is used to define groups of servers that can be referenced by fastCGI delivery, proxy delivery, UWSGI delivery, memcached delivery, and SCGI delivery instructions.
13. Please explain what is the C10K problem?
The C10K problem is the inability to handle a large number of clients (10,000) of network sockets simultaneously.
14. What are the functions of stub_STATUS and sub_filter directives?
Stub_status directive: This directive is used to know the current state of Nginx’s current state, such as the current active connections, the total number of read/write/wait connections accepted and processed
Sub_filter directive: This is used to search and replace the contents of the response and to quickly repair stale data
15. Explain whether Nginx supports compression of requests upstream.
You can use the Nginx module Gunzip to compress requests upstream. The gunzip module is a filter that decompresses responses using “content encoding :gzip” for clients or servers that do not support the “gzip” encoding method.
16, explain how to obtain the current time in Nginx.
To get the current time of Nginx, you must use the SSI module, dategmt and date_GMT, and variables dategmt and date_local.
Proxy_set_header THE-TIME $date_gmt;
17, What is the purpose of interpreting -s with Nginx server?
The executable used to run the Nginx -s argument.
18, Explain how to add modules to Nginx server.
During compilation, you must select the Nginx module because Nginx does not support runtime selection for modules.
The last
Thank you for reading here, the article is inadequate, welcome to point out; If you think it’s good, give me a thumbs up.