Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →To make Nginx accept a domain, point the domain’s DNS records at the server running Nginx, then create a server block whose server_name matches the requested hostname. Use a file-serving location for a static site or put proxy_pass inside location when the site runs on another port. For HTTPS, add a 443 SSL listener and certificate files that cover the hostname. Test the configuration, reload Nginx, and verify that the request is reaching the intended block rather than the default server.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
What “accept my domain” means in Nginx
Three separate systems must agree before a browser reaches the right site:
As an Amazon Associate I earn from qualifying purchases.
- DNS translates the domain (for example,
example.com) into the server address. Nginx cannot receive a hostname that still resolves elsewhere. - The listener, defined by
listen, chooses the local address and port, such as port 80 for HTTP or 443 for HTTPS. - The server block, selected by
server_name, chooses the configuration for the hostname within that listener.
NGINX documentation describes the relationship directly: server names are defined with the server_name directive and determine which server block is used for a request. A correct DNS record alone therefore does not configure a website, and a correct server block cannot compensate for DNS pointing to a different machine.
Before editing Nginx: gather the required details
Write down the exact hostnames you intend to serve and how the content is delivered. The answers determine the configuration you need.
#1 Best Overall
- Hostnames: decide whether you need the apex name (
example.com), thewwwname, both, or additional subdomains. - Server address: identify the public IPv4 and, if used, IPv6 address assigned to the Nginx server.
- Content type: static files in a document directory or an application listening on a local port such as
3000. - Ports: determine whether clients will use HTTP, HTTPS, or both. The application port normally stays private when Nginx is the public entry point.
- Certificate coverage: for HTTPS, obtain a certificate whose names include every hostname users will request. A certificate for
example.comdoes not automatically coverwww.example.comunless that name is also included.
Keep a rollback copy of the active configuration. A syntax error or an unintended default block can affect every site sharing the Nginx instance.
Step 1: Point DNS at the Nginx server
Create records for each hostname
At your domain registrar or DNS host, create the address records required for the names in your plan. An apex record generally points directly to the server address; a www name can point directly as well or be an alias where your DNS provider supports that record type. Provider labels differ, so use that provider’s current instructions for record names, TTLs, and alias behavior.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteIf you publish both IPv4 and IPv6 records, the server must be reachable and correctly configured on both protocols. Otherwise, some visitors can reach Nginx while others follow the unreachable address.
Allow time for DNS changes
DNS caches update according to the records’ TTL and the behavior of recursive resolvers. A record can appear correct at the authoritative DNS host while a particular network still has an older answer. Verify the result from more than one network or resolver before treating an Nginx configuration as faulty.
Confirm the destination before debugging Nginx
Resolve every hostname you plan to serve and compare the returned address with the Nginx server’s public address. If the result is wrong, fix DNS first. If it is correct but the browser shows another site, continue with server-block selection and default-server checks.
Step 2: Create a server block for a static website
Use exact names in server_name
For a static site, the minimum HTTP configuration looks like this:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
server {
listen 80;
server_name example.com www.example.com;
location / {
root /var/www/example;
index index.html;
}
}
listen 80 accepts HTTP traffic on port 80. The two names on server_name make the same block eligible for requests whose Host header is either example.com or www.example.com. The root directive maps URL paths to files below /var/www/example, and index identifies the default file for a directory request.
Place the files and permissions deliberately
Put the site’s entry file at /var/www/example/index.html and ensure the Nginx worker can read the directory and its contents. A readable directory with an unreadable file can produce an access error even when the server block matches. Keep application source, secrets, and writable data outside the public document root unless they are intentionally meant to be downloadable.
Enable the configuration used by your distribution
Linux packages organize configuration differently. Some load every file in a configuration directory; others provide separate “available” and “enabled” directories or an include statement in the main file. Put the server block where the main Nginx configuration includes it, and inspect the active configuration rather than assuming that a newly created file is loaded.
Step 3: Route a domain to an application on another port
Proxy requests inside location
If the application listens on a local port, Nginx acts as the public HTTP server and reverse proxy:
server {
listen 80;
server_name example.com www.example.com;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
}
}
The official reverse-proxy guidance specifies that proxy_pass is placed inside a location. Here, a request for any path under / is sent to the application at 127.0.0.1:3000. The application does not need to be exposed directly to the Internet.
Preserve the host and client address when the app needs them
proxy_set_header Host $host forwards the domain that the visitor requested. Frameworks use this value for virtual-host routing, canonical URLs, and security checks. proxy_set_header X-Real-IP $remote_addr passes the connecting client’s address in a header the application can read. Configure the application to trust that header only when requests can reach it through a trusted Nginx path; otherwise a client could supply a forged value.
Rank #3
Match the upstream address to the process that is actually listening
Use the loopback address when the application and Nginx share a server and the app is bound locally. If the application is on another machine, replace the upstream with that machine’s reachable address and make sure its firewall permits traffic from the Nginx host. A connection-refused error means the process is stopped, listening on a different port or address, or blocked before Nginx can connect.
Decide how multiple application paths should behave
A single location / sends all paths to the same upstream. Add more specific locations only when a separate path has a different destination or static handling. Keep the path rules intentional: overlapping prefixes can send a request to a block you did not expect, while a missing location leaves it to the broader match.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Step 4: Add HTTPS for the domain
Create an SSL listener and reference the certificate
HTTPS requires a listener on port 443 plus a certificate and private key:
server {
listen 443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/ssl/example/fullchain.pem;
ssl_certificate_key /etc/ssl/example/privkey.pem;
location / {
root /var/www/example;
index index.html;
}
}
The ssl parameter on listen enables TLS for that listener. ssl_certificate points to the certificate chain file and ssl_certificate_key points to the matching private key. Protect the key from unprivileged users and do not place it under a public document root.
Ensure the certificate covers every requested name
The certificate must include the hostname in the browser request. If a visitor requests www.example.com but the certificate names only example.com, the TLS handshake can fail or the browser can report a name mismatch. The same issue occurs when Nginx selects a different SSL server block and presents that block’s default certificate.
Give HTTPS the same content or proxy behavior
The 443 block needs its own location rules. Copy the static root configuration or the application proxy configuration into the SSL block, adjusting only what should differ. Defining a correct HTTP block does not automatically route HTTPS requests; each listener performs its own server-name selection.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #4
Handle HTTP and HTTPS as separate choices
You can serve both protocols, redirect HTTP to HTTPS, or keep HTTP available for a specific purpose. If you create a redirect, make it an intentional HTTP server block and leave the content-serving block on 443. Do not assume that adding a certificate changes port-80 behavior by itself.
How Nginx chooses the block when several sites share one server
Nginx first groups server blocks by the address and port selected by listen. Within that listener it compares the request’s Host header with server_name. An exact matching name should select the corresponding block; wildcard and other documented name forms are considered according to Nginx’s name-matching rules. If nothing matches, Nginx sends the request to the default server for that address and port.
| Configuration element | What it controls | Typical mistake |
|---|---|---|
listen |
Local address and port that accept the connection | Configuring 443 while testing an HTTP request on 80, or binding a different address than the one receiving traffic |
server_name |
Hostname match within that listener | Omitting the apex or www name, or spelling the name differently from DNS and the browser request |
default_server |
Catch-all block used when no name matches | Leaving an unintended site as the default, so unknown or misspelled hosts display the wrong content |
location |
Path handling after the server block is selected | Putting proxy_pass outside a location or allowing a broad rule to override a specific path |
Use listen 80 default_server; only on the block that should intentionally handle unmatched HTTP requests. Apply the same principle independently to the 443 listener; an HTTP default does not determine the HTTPS default.
Why Nginx shows the default site, and how to fix it
The Host header does not match
Check the exact hostname in the address bar, including whether it starts with www. Add every intended name to server_name or correct the request to use a name already listed. A request made directly to an IP address normally has no matching domain name and is likely to land on the default block.
The block is not loaded
A file can exist on disk without being included by the running configuration. Confirm the include paths in the main Nginx configuration and, on systems with separate enabled-file directories, create the required link or activation entry. Inspect the complete parsed configuration to see whether your server block appears.
Another block is the default
When two blocks listen on the same address and port, the first loaded block may become the default unless one is explicitly marked with default_server. Remove or disable an obsolete default site, or designate the intended catch-all block explicitly. Do not mark every block as default; only one default is valid for a given address-and-port combination.
Best Value
DNS still points elsewhere
If the request never reaches this server, no Nginx change can affect the result. Recheck the DNS answer from the network where the problem occurs, including IPv6 if an AAAA record is published.
HTTP and HTTPS select different blocks
A site can work on port 80 while the browser receives a different page or certificate on 443. Compare the server_name, enabled files, and default-server designation in both listeners. Ensure the HTTPS block contains the intended content or proxy location.
Free tools Windows power users keep installed
One-click scans. No signup required.
Wildcards and internationalized domain names
Wildcard names
Nginx supports documented wildcard syntax for names such as *.example.com. A wildcard is not the same as listing the apex name: *.example.com covers subdomains but does not, by itself, cover example.com. Include the apex explicitly when it should serve the same site. Use the narrowest wildcard that matches your tenancy or routing plan so an unintended subdomain does not enter the wrong block.
Internationalized domain names (IDNs)
Internationalized names are represented in DNS and Nginx configuration with their Punycode form. Convert the intended hostname to its ASCII-compatible representation and use that value in server_name. Keep a record of the human-readable form for operations, but compare the actual request and certificate names using the encoded form Nginx expects.
Large sets of names and hash errors
Nginx builds a hash for server names. With a very large or unusually long collection of names, startup can report that it cannot build the server-name hash. Follow the startup error’s instruction to increase server_names_hash_bucket_size or server_names_hash_max_size in the appropriate http context, then test again. Increase only the setting identified by the error; changing unrelated listener or location directives will not resolve a hash-capacity problem.
Validate safely before reloading
- Check syntax: run Nginx’s configuration test command (commonly
nginx -t) with the same privileges and configuration path used by the service. Do not reload while the test reports an error. - Read the reported files and line numbers: fix missing semicolons, unmatched braces, invalid directives, certificate paths, and permission problems exactly where reported.
- Reload, do not stop: use your operating system’s service manager to reload Nginx after a successful test. A reload lets existing connections finish while workers adopt the new configuration; a full stop creates an avoidable outage.
- Test each hostname and protocol: request
http://example.com,http://www.example.com,https://example.com, andhttps://www.example.comwhen all are intended. Check that static files, redirects, or the upstream response match the chosen design. - Test an unmatched name: use a deliberately unknown Host value to confirm that the configured default block, not a private site’s content, handles it.
When diagnosing a proxy, test the application directly on its local port from the Nginx server as well as through the domain. A direct failure points to the application or its listener; a direct success with a domain failure points to Nginx, DNS, TLS, or firewall routing.
Recommended Free Tools
Configuration patterns at a glance
| Use case | Hostname coverage | Listeners | Request destination | Important details |
|---|---|---|---|---|
| Static HTTP site | Exact names such as example.com www.example.com |
HTTP on 80 | Files below a root directory |
Directory and file permissions must allow Nginx to read the content |
| Application over HTTP | Exact names or an intentional wildcard | HTTP on 80 | proxy_pass target inside location |
Forward the original Host and client address when the application requires them |
| Static HTTPS site | Every certificate name listed in server_name |
HTTPS on 443 with ssl |
Files below a root directory |
Certificate and private-key paths must match and be readable by Nginx |
| HTTPS application | Every public application hostname | HTTPS on 443 with ssl |
Upstream application through proxy_pass |
Duplicate the proxy location in the 443 block; HTTP and HTTPS are separate listeners |
Common failure symptoms and targeted remedies
- DNS resolves to an old server: update the record at the authoritative DNS host and wait for caches governed by its TTL.
- The default Nginx welcome page appears: verify the Host name, whether the custom block is enabled, and which block is marked or implicitly acting as
default_server. - Static requests return an error: check the
rootpath, the presence of the index file, and read/execute permissions on every parent directory. - The proxy returns a gateway error: confirm that the application is running on the configured address and port, then check local firewall rules and the upstream bind address.
- The browser reports a certificate name error: ensure the selected 443 block presents a certificate containing the requested hostname, not merely a certificate for a related name.
- Only one of
wwwand the apex works: add both names to the relevant blocks and publish DNS records for both, or intentionally redirect one to the other. - One network works and another fails: compare cached DNS answers and IPv4 versus IPv6 paths; a stale or unreachable AAAA destination can bypass the working IPv4 server.
- Nginx refuses to start after adding many names: use the hash-size directive named in the startup error, then rerun the configuration test.
A repeatable deployment checklist
- List the exact apex,
www, wildcard, and subdomain names the site must answer. - Point each name’s DNS record to the Nginx server’s reachable address and verify both address families you publish.
- Choose a static
rootor an upstreamproxy_passtarget and confirm that target works locally. - Create a server block with the correct
listenport and completeserver_namelist. - Add the appropriate
locationrules for files or proxying, including the Host header forwarding required by the application. - For HTTPS, add a separate 443 SSL block and certificate files covering every requested hostname.
- Inspect default-server behavior so an unmatched name cannot expose the wrong site.
- Run the Nginx configuration test, correct every reported error, and reload only after a successful test.
- Test each hostname on HTTP and HTTPS, then test an intentionally unmatched hostname to verify the catch-all behavior.
Following that sequence isolates DNS, listener, hostname matching, content routing, and certificate problems instead of changing all five layers at once.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




