Top 50 Nginx Interview questions and answers

Nginx

Table of Contents

1) What is Nginx?

Nginx is a type of an open source web server which is especially used for reverse proxy, load balancer, mail proxy and for the HTTP cache. Nowadays NGINX software is most commonly used by various companies. NGINX can run on Linux, Mac OS X, Solaris, AIX, HP-UX, and the BSD variants.

2) In what language was the Nginx software being written?

The language in which the Nginx software is written is ‘C’ Language.

3) What are the main tasks of the Nginx web server?

The following are the main tasks of the Nginx web server:

The main task of the Nginx web server is to deploy dynamic HTTP content on a network using SCGI, Fast CGI handlers for scripts, WSGI application servers or Phusion passenger module.
Nginx is also used to serve as a load balancer.

4) What is the official website of Nginx web server?

The official website of the Nginx web server is Nginx.org

5) What are the difference between Nginx and Apache?

The following are the differences between Nginx and Apache:

Firstly, Nginx is an event-based web server and Apache is a process-based server.
Nginx is best known for its speed and Apache is best known for its power.
Nginx is the best when it comes to memory consumption and connection whereas Apache is not best in this category.
In Nginx, a single thread is handling all of the requests whereas in Apache single thread handles a single request.
Nginx is best when you want the load balancing. But Apache will refuse the new connection when traffic reaches the limit of the process.
Apache provides lots of functionality as compared to Nginx.

6) What are the types of versions of Nginx web server?

The following are the types of versions of Nginx web server:

Mainline - This version of Nginx contains latest features and bug fixes that are up to date. It is also reliable but it may contain some experimental modules.
Stable- This version of Nginx doesn’t have the latest features but has critical bug fixes. A stable version is always recommended for the production servers.

7) What is the master processor in Nginx?

A master processor in Nginx performs the privileged operations such as reading configuration and binding to ports.

8) What is work processor in Nginx?

A work process in Nginx actually does the whole processing of the requests.

9) What is the use of sub_status directives in Nginx?

The sub status directives is mainly used to know all the current status of Nginx. You can know the current active connections, total connections that are being accepted and all the handled current number of read, write and wait connections.

10) What is the purpose of the –s with Nginx Server?

The main purpose of the –s parameter is to run the executable files.

11) What are the controls used in the Nginx web server?

The following are the main controls used in the Nginx web server:

Stop
Quit
Reopen
Reload

12) What is the CSK10 problem for which the Nginx web server was discovered?

CSK10 problem is being referred to the network socket that failed to handle a large number of clients at the same time.

13) How to start Nginx server through other ports?

If you want to start the Nginx server, then you have to go to/ etc/ Nginx / site enabled/ and if there is a default file, then you have to open a file called default.

14) How can you add module in the Nginx server?

Firstly, you have to select the Nginx module during the compile. Runtime selection of module is not being supported by the Nginx server.

15) What is a directive in Nginx?

A directive in NGINX is used to route the server where to look for a resource by including files and folders while matching a location block against a URL.

16) What is the advantage of using a “reverse proxy server”?

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.

17) 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

Like server { listen 81; }

18) In Nginx, explain how you can keep double slashes in URLs?

To keep double slashes in URLs you have to use merge_slashes_off;

Syntax: merge_slashes [on/off]

Default: merge_slashes on

Context: http, server

19) Explain what is ngx_http_upstream_module is used for?

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.

20) Explain what is C10K problem?

C10K problem is referred for the network socket unable to handle a large number of client (10,000) at the same time.

21) What Is Nginx Server?

Nginx is an open supply web server and a opposite proxy server for HTTP,SMTP, POP3, and IMAP protocols with a robust attention on excessive concurrency,performance and low reminiscence utilization. It is stated as “engine x”.

22) In Which Language Nginx Is Written?

‘C’ Language.

23) What Is Official Website Of Nginx?

nginx.Org

24) What Is The Difference Between Apache Web Server And Nginx?

Nginx uses an asynchronous occasion technique to managing a couple of requests whereas Apache Web Server use the synchronous. Nginx’s event­pushed method can provide more predictable overall performance under excessive loads.
Apache Web Server managing more than one
Nginx dealing with more than one—–B———–way, Nginx is a ways higher than Apache

25) What Are Features Of Nginx?

Simultaneous Connections with low reminiscence
Auto Indexing
Load Balancing
Reverse Proxy with Caching
Fault Tolerance

26) Explain How You Can Start Nginx Through A Different Port Other Than eighty?

To start Nginx through a unique port, you have to visit /and many others/Nginx/sitesenabled/ and if that is the default report, then you need to open document known as “default.” Edit the report and put the port you need
Like server listen eighty one?

27) Where The Process Id Does For Nginx Server?

The manner ID of the master procedure is written inside the file /usr/neighborhood quit 13. What Is The Purpose Of –s With Nginx Server?

28) How To Add Modules In Nginx Server?

Answer :

Nginx modules should be selected throughout collect.
Run­time selection of modules is not supported by using Nginx.

29) What Is The Advantage Of Using A “reverse Proxy Server”?

The reverse proxy server can cover the presence and traits of the beginning server. It acts as an intermediate among internet cloud and internet server. It is ideal for safety cause specially while you are using internet hosting services.

30) In Nginx, Explain How You Can Keep Double Slashes In Urls

To preserve double slashes in URLs you have to use merge_slashes_off?
Syntax: merge_slashes [on/off]
Default: merge_slashes on
Context: http, server

31) What Is Ngx_http_upstream_module Is Used For?

The ngx_http_upstream_module is used to define corporations of servers which could reference through the fastcgi skip, proxy skip, uwsgi bypass, memcached pass and scgi pass directives.

32) What Is C10k Problem?

C10K problem is referred for the network socket unable to handle a big range of client (10,000) at the identical time.

33) What Is The Use Of Stub_status And Sub_filter Directives?

Stub_status directive: This directive is used to understand the modern-day fame of Nginx like contemporary lively connection, total connection well-known and treated current variety of read/write/wait connection
Sub_filter directive: It is used to search and replace the content material in reaction, and brief restore for stale data

34) Explain Does Nginx Support Compress The Request To The Upstream?

You can compress the request to the upstream by way of the use of the Nginx module gunzip. The gunzip module is a filter that decompresses responses with “Content Encoding: gzip” for customers or servers that don’t guide “gzip” encoding technique.

35) Explain How You Can Get The Current Time In Nginx?

To get the cutting-edge time in Nginx, you need to use variables from SSI module, $date_gmt and $date_local.

Proxy_set_header THE­TIME $date_gmt?

36) Explain How To Add Modules In Nginx Server?

During the compilation method, Nginx modules must be selected as such runtime selection of modules isn’t always supported with the aid of Nginx.

37) Explain How Nginx Can Handle Http Requests?

Nginx makes use of the reactor sample. The important occasion loop waits for the OS to sign a readiness event­ such that the information is out there to read from a socket, at which example it’s miles study into the buffer and processed. A Single thread can serve tens of lots of simultaneous connections.

38) In Nginx How You Can Prevent Processing Requests With Undefined Server Names?

A server that simply drops the requests can be defined as Server

concentrate eighty?
server_name “ “ ?
go back 444?

Here the server call is kept as an empty string which will fit request without the “Host” header field, and a unique Nginx’s non­wellknown code 444 is returned that terminates the relationship.

39) Define Some Special Features Of Nginx?

Special features of the Nginx server includes :

Reverse proxy/ L7 Load Balancer
Embedded Perl interpreter
On the fly binary improve
Useful for re­writing URLs and excellent PCRE aid

40) How To Reload Configuration File Of Nginx Server?

You can reload Nginx configuration record by way of jogging this command: nginx -­s reload

41) What Is The Difference Between Apache Web Server And Nginx?

Nginx uses an asynchronous event approach to handling multiple requests whereas Apache Web Server use the synchronous. Nginx’s event­driven approach can provide more predictable performance under high loads.
Apache Web Server handling multiple request
|—­A—–||—–B———–||——­C——|
Nginx handling multiple request
|—­A—–|
|—–B———–|
|——­C——|

In this way, Nginx is far better than Apache.

42) 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/sitesenabled/ and if this is the default file, then you have to open file called “default.” Edit the file and put the port you want
Like server { listen 81; }

43) Where The Process Id Does For Nginx Server?

The process ID of the master process is written in the file /usr/local/nginx/logs/nginx.pid

44) What Is The Purpose Of –s With Nginx Server?

-s parameter is used to run the executable file of nginx.

45) How To Add Modules In Nginx Server?

Nginx modules must be selected during compile.
Run­time selection of modules is not supported by Nginx.

46) Explain Is It Possible To Replace Nginx Errors Like 502 Error With 503?

502= Bad gateway
503= Server overloaded
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;
error_page 502 =503/error_page.html;

}

47) In Nginx, Explain How You Can Keep Double Slashes In Urls?

To keep double slashes in URLs you have to use merge_slashes_off;
Syntax: merge_slashes [on/off]
Default: merge_slashes on
Context: http, server

48) What Is Ngx_http_upstream_module Is Used For?

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.

49) How To Reopening The Log Files In Nginx Server?

You can use nginx –s reopen

50) How to start and stop nginx server?

Run the below command to start Nginx server:

sudo systemctl start nginx

Rajesh Kumar
Follow me
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Madhava
Madhava
1 year ago

It is awesome looking experience

1
0
Would love your thoughts, please comment.x
()
x