Web sitesi Türkiye'de bulunan bahis şirketi Mostbet, dünya çapında yüksek güvenilirliği ve güvenliği ile ünlüdür. Burada şansınızı bir çevrimiçi kumarhanede deneyebilir veya spor bahislerine katılabilirsiniz; ayrıca mükemmel bonuslar ve promosyonlar, ücretsiz bahisler, bedava çevirmeler, yüksek oranlar ve hızlı para çekme işlemleri de bulacaksınız. Ve mobil uygulamamız oyunun tadını sonuna kadar çıkarmanızı sağlayacak!

NGINX Configuration Information: Find out how to Get Began

What are Location Blocks?

NGINX’s location setting helps you arrange how NGINX responds to requests for sources contained in the server. Because the server_name directive informs NGINX the way it ought to course of requests for the area, location directives apply to requests for sure folders and information (e.g. http://instance.com/weblog/.) .

Let’s take into account a couple of examples:

File: /and many others/nginx/sites-available/instance.com

location / { }

location /photographs/ { }

location /weblog/ { }

location /planet/ { }

location /planet/weblog/ { }

These places are literal string matches and match any a part of an HTTP request following the host section:

Request: http://instance.com/

Returns: Let’s assume there’s a server_name entry for instance.com. On this case, the situation/directive determines what happens with this request.

With NGINX, requests are at all times fulfilled with essentially the most particular match doable:

Request: http://instance.com/planet/weblog or http://instance.com/planet/weblog/about/

Returns: This will likely be fulfilled by the situation /planet/weblog directive because it’s extra particular, regardless of location /planet being a match too.

File: /and many others/nginx/sites-available/instance.com

location ~ IndexPage.php$ { }

location ~ ^/BlogPlanet(/|/index.php)$ { }

When location directives are adopted by a ~ (tilde), NGINX performs an everyday expression match, which is at all times case-sensitive.

For instance, IndexPage.php could be a match with the primary of the above examples, whereas indexpage.php wouldn’t.

Within the second instance, the common expression ^/BlogPlanet(/|/index.php)$ { } would match requests for /BlogPlanet/ and /BlogPlanet/index.php however not /BlogPlanet, /blogplanet/, or /blogplanet/index.php. NGINX makes use of Perl Appropriate Common Expressions (PCRE).

What if you happen to choose matches to be case-insensitive? It is best to use a tilde adopted intently by an asterisk: ~*. You’ll be able to see the above examples outline that NGINX ought to course of requests ending in a sure file extension: the primary instance determines that information ending in .pl, PL, .cgi, .perl, .Perl, .prl, and .PrL (in addition to others) will all be a match for the request.

File: /and many others/nginx/sites-available/instance.com

location ^~ /photographs/IndexPage/ { }

location ^~ /weblog/BlogPlanet/ { }

Whenever you add a caret and a tilde (^~) to location directives, you’re informing NGINX that, ought to it match a selected string, it ought to cease looking for extra particular matches and make the most of these directives right here as an alternative.

Past this, these directives perform because the literal string matches do within the first group. Even when a extra particular match comes alongside at a later level, the settings will likely be utilized if a request is a match for one among these directives.

Now, let’s take a look at extra particulars on location directive processing.

File: /and many others/nginx/sites-available/instance.com

Lastly, including an equals image to the situation setting forces a precise match with the requested path and finally ends up looking for extra particular matches.

So, for instance, the final instance will likely be a match for http://instance.com solely, versus http://instance.com/index.html. In case you use precise matches, you possibly can improve the velocity of request occasions reasonably. This will show helpful if sure requests are prevalent.

The processing of directives will comply with this move:

  1. Actual string matches will likely be processed first: NGINX stops looking if a match is positioned and can fulfill the request.
  2. Any remaining literal string directives will likely be processed subsequent. NGINX will cease and fulfill a request if it finds a match utilizing the ^~ argument. If not, NGINX will proceed the processing of location directives.
  3. Every location directive with an everyday expression (~ and ~*) will likely be processed subsequent. If an everyday expression matches the request, NGINX will finish its search and fulfill the request.
  4. Lastly, if there are not any matching common expressions, the literal string match that’s most particular will likely be used.

Make sure that each file and folder discovered underneath a website is a match for a number of location directives.

Nested location blocks are usually not beneficial or supported.

Find out how to Use Location Root and Index

The situation setting is one other variable with its personal argument block.

When NGINX has recognized the situation directive that’s the finest match for a particular request, its response will likely be primarily based on the related location directive block’s contents. So, as an example:

File: /and many others/nginx/sites-available/instance.com

location / {

root html;

index index.html index.htm;


We are able to see, on this instance, that the doc root is predicated within the html/ listing. Below the NGINX default set up prefix, the situation’s full path is /and many others/nginx/html/.

Request: http://instance.com/weblog/contains/type.css

Returns: NGINX will attempt to serve the file discovered at /and many others/nginx/html/weblog/contains/type.css

Please notice:

Absolute paths for the foundation directive can be utilized if you want. The index variable informs NGINX which file it ought to serve if none are specified.

So, as an example:

Request: http://instance.com

Returns: NGINX will attempt to serve the file discovered at /and many others/nginx/html/index.html.

When numerous information are specified for the index directive, the checklist will likely be processed so as, and NGINX will fulfill the request with the primary file discovered to exist. If index.html can’t be positioned within the related listing, index.htm will likely be utilized as an alternative. A 404 message will likely be delivered if neither exists in any respect.

Let’s take into account a extra complicated instance that showcases a number of location directives for a server responding to the instance area:

File: /and many others/nginx/sites-available/instance.com location directive

location / {

root /srv/www/instance.com/public_html;

index index.html index.htm;


location ~ .pl$ {

gzip off;

embrace /and many others/nginx/fastcgi_params;

fastcgi_pass unix:/var/run/fcgiwrap.socket;

fastcgi_index index.pl;

fastcgi_param SCRIPT_FILENAME /srv/www/instance.com/public_html$fastcgi_script_name;


Right here, we will see that the second location block handles all requests for sources ending in a .pl extension, and it specifies a fastcgi handler for them. NGINX will use the primary location directive in any other case.

Assets are discovered on the file system at /srv/www/instance.com/public_html/. When no precise file names are outlined within the request, NGINX will seek for the index.html or index.htm file and supply it. A 404 error message will likely be returned if zero index information are positioned.

Let’s take into account what takes place throughout numerous instance requests:

Request: http://instance.com/

Returns: /srv/www/instance.com/public_html/index.html if this exists. In any other case, it should serve /srv/www/instance.com/public_html/index.htm. And if each of those don’t exist, a 404 error will likely be offered.

Request: http://instance.com/weblog/

Returns: /srv/www/instance.com/public_html/weblog/index.html if this exists. If the file can’t be discovered as a result of it doesn’t exist, a /srv/www/instance.com/public_html/weblog/index.htm will likely be served. If neither exists, NGINX will return a 404 error.

Request: http://instance.com/duties.pl

Returns: NGINX will benefit from the FastCGI handler to execute the file discovered at /srv/www/instance.com/public_html/duties.pl and return the related consequence.

Request: http://instance.com/username/roster.pl

Returns: NGINX will make the most of the FastCGI handler to execute the file discovered at /srv/www/instance.com/public_html/username/roster.pl and return the related consequence.


Mastering NGINX configuration is crucial for optimizing internet server efficiency and effectively managing web site sources. By understanding directives, blocks, and their implications, directors can tailor NGINX to satisfy the calls for of their particular use instances. 

This information offered a foundational understanding of NGINX configuration, empowering customers to harness its capabilities successfully.

Environment friendly NGINX configuration is essential for optimum server efficiency. Think about implementing NGINX performance-tuning methods corresponding to load balancing and caching within the HTTP block for even higher scalability and responsiveness.