Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesTo serve a static site, place the HTML files in a directory, point a server block at that directory with root, define the host and port with listen and server_name, set an index file, and test and reload the active configuration.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
server {
listen 80;
server_name example.com www.example.com;
root /data/www;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
With this configuration, /data/www/index.html answers the request for /, while /data/www/about.html answers /about.html. The sections below explain how Nginx selects this block, maps URLs to files, handles missing pages, and applies changes safely.
As an Amazon Associate I earn from qualifying purchases.
What Nginx must decide for every request
A static request still passes through several configuration decisions. Nginx first chooses a virtual server from the listening address and port plus the request’s Host value. The matching server_name can be an exact name, a wildcard, or a regular-expression name. After selecting the server block, Nginx chooses the applicable location. That location supplies (or inherits) the file-mapping rule and any request handling directives.
For a normal document root, root is a directory on the server. Nginx appends the request URI to that directory to form a local pathname. If the active root is /data/www, a request for /about.html maps to /data/www/about.html. This URI-to-path relationship is the central rule behind a static site configuration.
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Prepare the files and configuration context
Choose a document root
Create or select a directory that will contain the site. The official beginner example uses /data/www. Put the home page at /data/www/index.html and additional documents beside it, such as /data/www/about.html. Preserve the URL structure you intend to publish: a request for /css/site.css requires a readable file at /data/www/css/site.css when the root is /data/www.
Check ownership and read permissions
The Nginx worker processes must be able to traverse the directories and read the files. A correct URI and a correct root still produce an error if a parent directory blocks traversal or a file is unreadable. Check permissions and ownership using the conventions of your operating system and package. Do not assume that the account used to edit files is the same account used by Nginx workers.
Find the active packaged configuration
Distributions package Nginx differently. The file you edit might be the main configuration, an included site file, or a distribution-specific enabled-sites path. Confirm which file is actually included by the running Nginx instance before changing it. A syntactically valid file has no effect if it is outside the active configuration tree.
The minimal static-site server block
Use this as a starting point, replacing the host names and filesystem path with your values:
server {
listen 80;
server_name example.com www.example.com;
root /data/www;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
| Directive | Role in this configuration | Example value |
|---|---|---|
listen |
Selects the local address and port on which this server block accepts requests. | 80 |
server_name |
Matches the requested host name; exact, wildcard, and regular-expression names are supported. | example.com www.example.com |
root |
Sets the directory used to construct file paths from request URIs. | /data/www |
index |
Lists default files to try when a request addresses a directory, in the order written. | index.html |
location / |
Matches requests under the site root and applies the enclosed directives. | / |
try_files |
Checks candidate files or directories in order and returns the chosen result or fallback. | $uri $uri/ =404 |
The server block must be inside the configuration’s http context. Putting it at top level, inside the wrong context, or in a file that is never included prevents the intended site from loading.
How Nginx maps a request to an HTML file
1. Select the virtual server
Nginx compares the request’s destination address and port with listen directives, then evaluates server_name. An exact host name is the narrowest choice for a named site. Wildcards cover a family of names, while regular expressions can express more complex patterns. If no configured name matches, another server block may answer the request, which often looks like a missing-file problem even though the files are present.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
2. Select the location
Nginx evaluates the request URI against the available location blocks. The location / block in the minimal example provides a general rule for the site’s paths. More specific locations can handle assets, errors, or other subtrees separately.
3. Construct the filesystem path
With root /data/www, the URI is appended to that root. Thus / refers to the directory /data/www, and /about.html refers to /data/www/about.html. The same rule applies to nested paths such as /images/logo.svg, which maps to /data/www/images/logo.svg unless a more specific location changes the mapping.
4. Resolve a directory request with index
When the request identifies a directory, the index directive supplies filenames to test. Nginx’s documented default is index.html; stating it explicitly makes the intended behavior visible and lets you control the order if you add alternatives. If an index file is found, Nginx performs an internal redirect to that file’s URI and processes the new URI through location selection again. This means a rule that applies to the resulting /index.html request can affect the final response.
Use try_files to control missing paths
try_files checks candidates from left to right, constructing each candidate from the active root or alias. It uses the first existing file or directory for request processing. If no candidate exists, the last argument determines what happens.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Return a direct 404
location / {
try_files $uri $uri/ =404;
}
Here, Nginx first checks the exact URI as a file, then as a directory, and finally returns status 404 when neither exists. This is the clearest choice for a site where unknown URLs should fail rather than be rewritten to another document.
Send a missing request to a fallback URI
The final argument can be a URI instead of a status code. That causes an internal redirect to the fallback, which must have a corresponding location and file. A fallback is useful when the site has an application-style front controller or a custom error route, but it changes the semantics of unknown paths: they no longer automatically become direct 404 responses.
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Check alternate static forms
The official rewrite documentation demonstrates ordered checks such as $uri, $uri/index.html, and $uri.html. A site can use this pattern when it wants clean URLs to resolve to directories or extension-bearing files:
try_files $uri $uri/index.html $uri.html =404;
Only add candidates that reflect files you actually publish. Every additional candidate changes which resource wins when more than one path exists.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Pointing Nginx at index.html
For a request to /, set the document root to the directory containing the home page and include index index.html;. Nginx checks the configured index names in order. If /data/www/index.html exists and is readable, it becomes the response document through the internal redirect described above.
If the browser receives a directory listing, an error, or a different page, check these conditions in order:
- The requested host reaches the intended
serverblock. - The active
rootis the directory that actually containsindex.html. - The file name uses the exact case present on the filesystem.
- The Nginx workers can traverse the root and read the file.
- The edited configuration is included by the running instance and was reloaded successfully.
Serve assets from a separate directory
A more specific location can map a URL subtree to another filesystem directory. The beginner guide demonstrates:
location /images/ {
root /data;
}
With this rule, a request such as /images/banner.png is mapped beneath /data, producing /data/images/banner.png. The location’s root therefore includes the URL prefix when constructing the path. This differs from an alias, whose mapping replaces the matching location prefix; choose deliberately and verify the resulting path on disk.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Keep a general location / rule for the rest of the site and ensure that an asset-specific rule does not unintentionally override headers or fallback behavior needed elsewhere. Test an asset URL directly after adding the location.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
Add a custom 404 page and cache rules
Custom error document
Nginx can serve a static /404.html document through a dedicated location. Keep the error file inside the configured root and make sure the location does not create a redirect loop. The error handling rule should still return the intended 404 status while presenting the custom document.
Static-asset caching
The official example configuration includes static-file patterns with cache headers. Apply long-lived caching only to files whose names change when their contents change, such as versioned CSS, JavaScript, or image assets. If you overwrite a file without changing its URL, a long cache lifetime can leave visitors with an older copy. HTML documents generally need a shorter cache policy than fingerprinted assets, because they point browsers to the current site resources.
Exact names, wildcards, and multiple sites
Use exact names when a server block should answer only one known host. List both the bare and www names when both should reach the same files. Wildcard names are appropriate when many subdomains share a policy. Regular-expression names are the most flexible but also the easiest to make broader than intended.
When several server blocks listen on the same port, a request with an unexpected or missing Host header can land in a different block. During troubleshooting, request the site by its configured name and inspect which block is intended to be the default for unmatched traffic. A correct file path in the wrong server block still produces the wrong result.
Validate, reload, and verify the change
- Place the files. Copy
index.html, other HTML documents, and assets beneath the configured root. Confirm the spelling and case of every path used in test requests. - Check access. Verify directory traversal and file-read permissions for the Nginx worker processes. Correct ownership or mode settings using your operating system’s normal administration tools.
- Confirm inclusion. Make sure the edited
serverblock is inside thehttpcontext and is loaded by the active packaged configuration. - Run a syntax test.
nginx -tis the customary Nginx syntax test. Package wrappers may require their own invocation, so use the command provided by your operating system when it differs. - Reload Nginx. Use the service manager or Nginx control command supplied for your operating system. A reload applies the new configuration without treating a full stop and start as necessary; the exact command is platform-specific.
- Request known paths. Test the home page, a second HTML document, and a known asset. Include the host name that appears in
server_name. - Request a missing path. Use an intentionally nonexistent URI and confirm that the result matches your chosen
try_filesbehavior: a direct 404 or the configured fallback.
| Test request | Expected mapping or outcome | What a failure suggests |
|---|---|---|
/ |
Index processing finds index.html under the root. |
Wrong root, missing index, permissions, or wrong server block. |
/about.html |
The corresponding HTML file under the root is returned. | Filename or case mismatch, wrong root, or a location override. |
| A known asset path | The asset-specific or general root maps to an existing readable file. | Incorrect asset location, path construction, or permissions. |
| An intentionally missing URI | 404 with try_files ... =404, or the configured fallback URI. |
Unexpected rewrite or a different server block handling the request. |
Troubleshoot common failures
404 for a file that exists
First calculate the path Nginx should be using: combine the active root with the request URI. Check that exact path, including capitalization. Then verify that the request selected the intended server_name and location. Finally, test the configuration and reload it; editing an unused file cannot change the response.
403 or an unreadable response
A 403 commonly indicates that Nginx reached a directory or file but lacks permission to traverse or read it. Inspect every parent directory, not only the HTML file itself. If the request ends at a directory and no readable configured index exists, add the intended index file or adjust the index list rather than relying on directory browsing.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
The default site answers instead
An unmatched host name, an incorrect port, or a server block that was not included can send the request to another configuration. Test with the exact host name, check the listen value, and confirm the edited file belongs to the running configuration tree.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteChanges do not appear after editing
A syntax test does not apply changes by itself. After a successful test, perform the platform’s reload operation and repeat the known-page and missing-page checks. If the result is unchanged, verify that the reload targeted the same Nginx installation and configuration path that is serving traffic.
Choosing between common configuration patterns
| Decision | Option | When it fits |
|---|---|---|
| Document mapping | One root for the whole site |
HTML and assets share one predictable directory tree. |
| Document mapping | Specific roots for subtrees | An asset or content subtree lives under a separate filesystem directory and has its own location rule. |
| Index behavior | Explicit index index.html; |
You want the intended default file visible and controlled in the server block. |
| Missing paths | try_files $uri $uri/ =404; |
Unknown URLs should return a straightforward 404. |
| Missing paths | Final fallback URI | A site deliberately routes misses to a custom page or front-controller location. |
| Host matching | Exact names | Only specified domains should select the site. |
| Host matching | Wildcard or regular-expression names | Multiple related host names share one server policy. |
Operational checklist
- Is the requested host covered by the intended
server_name? - Does
listenmatch the address and port receiving traffic? - Is the
serverblock insidehttpand actually included? - Does
rootpoint to the directory containing the files? - Is
index.htmlpresent, correctly named, and readable? - Do more specific locations change the root or fallback for the path being tested?
- Does
try_filesexpress the desired missing-URL policy? - Did the syntax test pass before the reload?
- Was the correct service or Nginx instance reloaded?
- Do tests cover the home page, another document, an asset, and a deliberate miss?
Frequently Asked Questions
Can I omit the index directive if my home page is named index.html?
Nginx documents index.html as the default index filename, but declaring index index.html; makes the behavior explicit and keeps the server block self-documenting. It also gives you a clear place to order additional index names if the site later needs them.
Why does try_files $uri $uri/ =404; still return a 404 for a directory?
The directory must contain a readable configured index file for the directory request to resolve to a document. Check the directory’s index file, permissions, and the active root; try_files does not create an index file.
Does changing the configuration require stopping Nginx?
Normally you test the edited configuration and then use the operating system’s service-manager reload operation or the appropriate Nginx control command. The exact reload command depends on the package and operating system, so follow that platform’s service interface.
Recommended Free Tools
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.




