Top 18 Nginx Interview Question
Top 18 Nginx Interview Question
com/
Nginx is a web server and a reverse proxy server for HTTP, HTTPS, SMTP, POP3 and IMAP
protocols.
Nginx Apache
Nginx is an event based web server Apache is a process based server
All request are handled by a single Single thread handles a single request.
thread. Apache is based on child processes
Nginx avoids child processes idea. Apache resemble power
Nginx resembles speed Apache is not up-to the mark when it
Nginx is better when it comes to comes to memory consumption and
memory consumption and connection connection
Nginx is better when you want load- Apache will refuse new connections
balancing when traffic reaches the limit of
For PHP, Nginx might be preferable as processes
it supports PHP internally Apache support’s PHP, Python, Perl
Nginx do not support O.S like IBMi and and other languages using plugins. It is
OpenVMS. useful when application is based on
1/4
https://career.guru99.com/
Nginx uses the reactor pattern. The main event loop waits for the OS to signal a readiness
event- such that the data is accessible to read from a socket, at which instance it is read into the
buffer and processed. A Single thread can serve tens of thousands of simultaneous
connections.
5) In Nginx how you can prevent processing requests with undefined server names?
Server {
listen 80;
server_name “ “ ;
return 444;
Here the server name is kept as an empty string which will match request without the “Host”
header field, and a special Nginx’s non-standard code 444 is returned that terminates the
connection.
The reverse proxy server can hide the presence and characteristics of the origin server. It acts
as an intermediate between internet cloud and web server. It is good for security reason
especially when you are using web hosting services.
2/4
https://career.guru99.com/
The best usage of Nginx server is to deploy dynamic HTTP content on a network with using
SCGI, WSGI application servers, FastCGI handlers for scripts. It can also serve as a load
balancer.
9) Explain how you can start Nginx through a different port other than 80?
To start Nginx through a different port, you have to go to /etc/Nginx/sites-enabled/ and if this is
the default file, then you have to open file called “default.” Edit the file and put the port you want
10) Explain is it possible to replace Nginx errors like 502 error with 503?
Yes, it is possible but you to ensure 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;
#...
11) In Nginx, explain how you can keep double slashes in URLs?
3/4
https://career.guru99.com/
Default: merge_slashes on
The ngx_http_upstream_module is used to define groups of servers that can reference by the
fastcgi pass, proxy pass, uwsgi pass, memcached pass and scgi pass directives.
C10K problem is referred for the network socket unable to handle a large number of client
(10,000) at the same time.
Stub_status directive: This directive is used to know the current status of Nginx like
current active connection, total connection accepted and handled current number of
read/write/wait connection
Sub_filter directive: It is used to search and replace the content in response, and quick
fix for stale data
15) Explain does Nginx support compress the request to the upstream?
You can compress the request to the upstream by using the Nginx module gunzip. The gunzip
module is a filter that decompresses responses with “Content Encoding: gzip” for clients or
servers that do not support “gzip” encoding method.
16) Explain how you can get the current time in Nginx?
To get the current time in Nginx, you have to use variables from SSI module, $date_gmt and
$date_local.
During the compilation process, Nginx modules must be selected as such run-time selection of
modules is not supported by Nginx.
4/4
Powered by TCPDF (www.tcpdf.org)