Nginx. Working with virtual hosts
A virtual host is the configuration of a single site in Nginx: the domain, the port, the file root, and the request-handling rules. One Nginx process serves many sites, and each site corresponds to its own server block in the configuration. In BeAdmin, a host can be created and edited through a form with fields (builder mode), and for non-standard directives you can switch to expert mode and edit the raw config. This article covers builder mode: creating, editing, enabling and disabling, and deleting hosts. Installing the Nginx module itself and managing the service overall are covered in a separate article.
Creating a virtual host
- In the side menu of the Nginx section, click «Create virtual host».
- The page opens in builder mode. Fill in the fields and click «Create».
💡 Draft saving in the browser
If you start filling in the host creation form and close it without clicking «Create», the panel remembers your input — regardless of whether you were filling in the form in builder or expert mode. When you come back to creating a host, a dialog appears: «You have an unfinished form. Would you like to continue?» The «Resume» button loads the saved input back into the form. The draft is dropped after the host is successfully created or after an explicit refusal to continue.
What each form field means is described below.
Domain name
The host's domain name — the address at which the site will be reachable from the outside. The field accepts a domain name or an IP address (IPv4 or IPv6); the former is for an ordinary site, the latter is for cases when the server serves a site without a DNS record.
You cannot create two hosts with the same «domain + port» pair — if such a pair is already taken, the panel reports it and will not let you save the form. So example.com on 80 and on 8080 can be brought up at the same time, but example.com on 80 twice cannot.
After a host is created, the domain name cannot be changed — the field becomes read-only. If the domain has to change, it is easier to create a new host and delete the old one.
HTTPS or HTTP
The toggle «Use HTTPS (port 443)» / «Use HTTP (port 80)» switches the protocol and port together. HTTPS is on by default — this is the recommended option. When HTTPS is on, on host creation BeAdmin automatically issues a Let's Encrypt certificate and renews it from then on for as long as the host exists.
If certificate issuance fails, the host is created with a self-signed placeholder certificate, and the panel shows the notification «Virtual host configured with self-signed certificate». For details on how issuance works and how to reissue the certificate manually, see Issuing an SSL certificate; for a breakdown of specific error messages, see Resolving ACME errors when issuing an SSL certificate.
To run a site on a non-standard port (an internal service, several sites on different ports of the same domain), click «Specify port manually» and enter the number. Any free port in the 1–65535 range is allowed.
⚠️ HTTPS only on the standard port 443
BeAdmin issues Let's Encrypt certificates only on the standard HTTPS port 443. If you have chosen a non-standard port, run the site over HTTP; if HTTPS is required, attach your own certificate manually through expert mode.
Index file names
This field defines which files Nginx serves on a request to a directory — for example, when visiting https://example.com/. The default is index.html index.htm. The names are written on a single line separated by spaces, in priority order.
The characters ?, :, ,, ; are not allowed in the names — the panel rejects them and shows a warning.
If the host has a PHP location, index.php is automatically prepended to the list — there is no need to add it explicitly. When the PHP location is removed, index.php is removed from the list automatically as well.
Files directory
The site's file root — the value that ends up in the nginx config's root directive. The directory can be picked through the directory-picker dialog or entered by hand.
The directory must exist on the server and be readable by the Nginx process; otherwise the site responds with a 403 or a 404. If you plan to put the files there later, create an empty directory in advance.
Locations
Locations are location blocks in the nginx config that decide how requests to different URL paths are handled: serving static files, passing the request to PHP, proxying to another service, or making redirects. In the «Extra options» block below the main fields there is an «Add location» button that lets you pick a template:
- Root location — handles requests at the site root; always present in a host.
- Simple — a static response or basic file serving by path.
- PHP (FastCGI) — passes requests to PHP-FPM.
- Reverse proxy —
proxy_passto an upstream (for example, Apache, a Node app, or a Docker container).
Details on each template, and on adding and removing locations — in Nginx. How to configure locations for a virtual host.
Nginx and Apache together
If both modules are installed on the server, the layout is one and the same: Nginx sits in front and accepts requests from the internet on 80/443, and Apache works as a backend on the local ports 127.0.0.1:8808 (HTTP) and 127.0.0.1:8843 (HTTPS). PHP, .htaccess, and Apache modules are handled on the Apache side; Nginx proxies requests and, where appropriate, serves static files directly.
Auto-configuration only works one way. If Apache is installed when Nginx is already in place, BeAdmin itself picks the Apache backend listeners 127.0.0.1:8808/8843. But if Apache was installed first and Nginx is added on top, the Nginx module page shows a banner warning about the conflict, and Apache has to be put into backend mode manually: reinstall the Apache module in backend mode (on 127.0.0.1:8808/8843).
In an Nginx virtual host, a single «Reverse proxy» location with the address http://127.0.0.1:8808 is enough for this pairing — TLS is terminated on Nginx, so reaching out to 8843 is normally not needed. How to set up such a location is described in Nginx. How to configure locations for a virtual host. On Apache setup — see Apache. Quick start.
Editing a virtual host
Open a host from the side list of the Nginx section — the same form opens as for creation, with two differences:
- The «Domain name» field is read-only — the domain does not change after creation.
- The port is always shown as a separate field (without the HTTPS toggle) and can be changed directly. If you set 443,
BeAdminwill treat the host as an HTTPS site and issue a Let's Encrypt certificate on save.
To save changes, click «Update» — the button is active only when there are unsaved changes. As with creation, the panel validates the config before applying and, on error, leaves the previous working version in place.
Enabling and disabling a host
Next to the save button there is a host-state toggle:
- On the create page — «Enable virtual host» / «Disable virtual host» (initial state choice).
- On an existing host's page — «Host enabled» / «Host disabled» (current state; changed and saved with the «Update» button).
When a host is disabled, its main server block is removed from the configuration — the site stops responding to requests, but the host record and its settings stay in BeAdmin, and the host can be enabled again at any time. The SSL certificate continues to renew automatically. After re-enabling, the site comes back online over HTTPS without any extra steps.
Deleting a virtual host
A host can be deleted via the trash icon next to it in the side list. To rule out accidental deletion, the panel asks you to confirm by typing in the host name.
When a host is deleted, the Nginx config file and its logs are erased. The directory with the site's files (the one specified in the «Files directory» field) is preserved — this is a safeguard against data loss when a host is removed by accident. If the directory is no longer needed, delete it manually.
Expert mode
If the standard builder form is not enough — for example, you need a custom try_files, non-standard access_log, additional fastcgi_param, or rate limiting — switch to expert mode with the «Switch to expert mode» button at the bottom of the form. To switch back, use the «Switch to bulder mode» button.
Details on expert mode — the starter template, switching between modes without losing settings, and connecting PHP-FPM by hand — are in Nginx. Virtual hosts in expert mode.
See also
- Nginx. How to configure locations for a virtual host — rule templates, universal parameters, proxying.
- Nginx. Virtual hosts in expert mode — raw config, starter template, manual PHP-FPM wiring.
- Issuing an SSL certificate — how the panel issues Let's Encrypt and how to reissue the certificate manually.
- Resolving ACME errors when issuing an SSL certificate — what to do if Let's Encrypt did not issue.
- Apache. Quick start — setting up Apache together with Nginx.
- Official Nginx documentation — directive and module reference.