Create a Server Block in NGINX
A server block in NGINX is a configuration block that defines how the server handles incoming HTTP requests for a specific domain. It allows you to run multiple websites on a single server, specifying individual settings for each site: domain name, port, file path, PHP processing, and other parameters. Server blocks are the primary tool for deploying websites on a web server.
The server block settings consist of several key parameters. Below is a description of each and instructions on how to configure them using the BeAdmin
control panel.
Domain Name
The server_name
directive specifies the domain name through which the website will be accessible. It is used to match incoming HTTP requests to the correct server block based on the Host
header. Typically, this name corresponds to your website address (for example, example.com
).
Important
The domain name must follow standard naming rules — it should not contain invalid characters and must not exceed the maximum allowed length.
Connection Port
Most websites use the default connection ports:
- 80 — for HTTP
- 443 — for HTTPS (when an SSL certificate is installed)
For convenience, the interface allows you to choose between HTTP and HTTPS. In the NGINX configuration, the corresponding port will be automatically set in the listen
directive.
You can also specify a custom port in the range 1024–65535. Ports from 1 to 1023 are considered privileged and require administrator (root) permissions.
Please note: By default, BeAdmin
uses port 8080 — if you assign this port to a website, it may cause a conflict and make the site inaccessible.
Index File Names
The index
directive defines which file will be loaded by default when accessing a directory without specifying a file name. For example, when visiting example.com/
, NGINX will attempt to load index.html
, index.php
, or any other file defined here.
You can specify multiple index files, separated by spaces, in order of priority. Example:
index.php index.html index;
For PHP-based websites, index.php
is typically listed first.
Website Files Directory
The selected directory is used in the root
directive and determines where your website files are located on the server.
By default, the directory is created using the domain name as its folder name, but you can manually specify any path.
It is important that your index
file (such as index.php
or index.html
) is located in the chosen directory; otherwise, your website will not display correctly.
PHP Integration
If your website is static (HTML/CSS) and does not use PHP, you do not need to enable PHP.
For PHP-based websites, you need to select the PHP version to use. In this case, NGINX will pass PHP script processing to the selected PHP interpreter via PHP-FPM (FastCGI Process Manager) using the fastcgi_pass
directive.
If the required PHP version is not yet installed, you can select and install it directly from the server block creation interface.
Creating a Server Block
Once all parameters are configured, you can create the server block. After that:
- An NGINX configuration will be automatically generated.
- The server will start handling requests based on your settings.
If your website files are already placed in the specified directory, your website will be accessible online.
If you don't want to publish the site immediately, you can toggle the Enable Host
switch to off
— in this case, NGINX will ignore incoming requests until you manually enable the server block.