October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk11 min

How to Configure Apache to Serve Your App on Your Domain

A practical Apache guide covering DNS, name-based virtual hosts, DocumentRoot, reverse proxying, HTTPS, multi-domain setups, and diagnostics with apachectl.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To serve an app at your domain with Apache, complete two separate jobs: point the domain’s DNS records at the server’s public IP, then configure an Apache virtual host that answers for that hostname. A static app uses DocumentRoot; an app running on Node, Python, or another server uses Apache’s reverse-proxy directives. Validate the parsed configuration with apachectl -S and apachectl configtest before exposing HTTPS or redirecting traffic.

What must be in place before Apache can answer

Apache cannot create DNS records for a hostname. DNS and Apache are independent layers: DNS tells browsers which public IP address to contact, while Apache decides which site or backend should handle an HTTP request after it arrives.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Domain and server prerequisites

  • You control the domain’s DNS zone and can create or edit A records for IPv4 and, if applicable, AAAA records for IPv6.
  • The records for example.com and any name you intend to support, such as www.example.com, resolve to the server that runs Apache.
  • Apache is installed and listening on the intended interfaces and ports. HTTP normally uses port 80; HTTPS uses port 443.
  • Firewall rules, cloud security groups, and any hosting-provider network policy permit the ports you plan to use.
  • For a static site, you have a directory containing the built files. For a running app, you know its private bind address and port, such as 127.0.0.1:3000.

Allow time for DNS changes to reach different resolvers. Test from outside the server’s network, because a local hosts-file override or split-horizon DNS can hide a public misconfiguration.

How Apache chooses the virtual host

A name-based virtual host is a rule set associated with an IP address and port. Apache first narrows the candidates by destination IP and port. For HTTP, it then compares the request’s Host header with ServerName and ServerAlias. For HTTPS, the TLS handshake supplies the hostname through SNI before the encrypted request is processed.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

If no configured hostname matches, Apache serves the first name-based virtual host for that IP-and-port combination. That ordering explains why a request can display another site even when the new file looks correct: the request may be reaching the wrong address, using a hostname not covered by the vhost, or selecting an earlier default.

The directives you normally need

  • ServerName is the canonical hostname for the site.
  • ServerAlias adds other names, commonly www.example.com.
  • DocumentRoot points Apache at static files.
  • ProxyPass and ProxyPassReverse send requests to a running backend.
  • ErrorLog and CustomLog give the vhost separate diagnostics.

Keep each domain’s names, content or proxy target, and logs in its own vhost. This makes matching errors visible and prevents an unrelated site from becoming the accidental fallback.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Serve a static build from a domain

Use this model when Apache should read files directly: a generated frontend, documentation site, or other content that does not require a long-running application process.

1. Create the document root and deploy the files

Create a directory such as /var/www/example and copy the application’s built output into it. The directory must be readable by the account Apache uses, while write access should be limited to your deployment process. Confirm that the expected entry file, often index.html, is present at the root that you configure.

2. Create an HTTP virtual-host file

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example

    <Directory /var/www/example>
        AllowOverride None
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example-error.log
    CustomLog ${APACHE_LOG_DIR}/example-access.log combined
</VirtualHost>

AllowOverride None means Apache will not read per-directory .htaccess files for this tree. That avoids hidden overrides and is appropriate when all rules are managed in the vhost. If the application genuinely requires .htaccess, change the setting deliberately and grant only the overrides it needs.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

3. Enable the site and reload Apache

Save the file in the configuration directory used by your operating system and enable it using that distribution’s site mechanism. Debian-family packages commonly provide an a2ensite helper, while other layouts use an included configuration directory or a manually maintained include. Do not assume the path or helper name is identical across systems.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run a syntax check before reloading:

apachectl configtest

Only after the result reports a valid configuration should you reload Apache with the service manager supplied by your platform (for example, a reload action for the platform’s apache2 or httpd service). A reload normally preserves existing connections; a restart is more disruptive and is not required for an ordinary vhost edit.

4. Test both names

Request the bare domain and every alias, not just the name you typed in the browser:

curl -I http://example.com
curl -I http://www.example.com

Both requests should reach this vhost and return the expected status and headers. If one name shows a different site, inspect DNS and the hostname coverage before changing the document root.

Put a Node, Python, or other app behind Apache

Use reverse proxying when your application listens on a local TCP port and generates responses itself. Apache remains the public web server while the app stays private on the loopback interface unless you intentionally need direct access.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

1. Keep the backend private and stable

Configure the app to listen on the required address and port, for example 127.0.0.1:3000. Binding to loopback prevents unsolicited Internet connections to the backend. Make sure a process supervisor or service unit starts it after a reboot and restarts it according to your operational needs; Apache does not manage the application’s process lifecycle.

2. Enable the proxy modules required by your platform

Apache needs its proxy module and the protocol-specific module for the backend, commonly the HTTP proxy module. Module names and enablement commands differ by package layout. Confirm that the modules are loaded before testing the vhost.

3. Add a reverse-proxy virtual host

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    ProxyPreserveHost On
    ProxyPass        / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/

    ErrorLog ${APACHE_LOG_DIR}/example-error.log
    CustomLog ${APACHE_LOG_DIR}/example-access.log combined
</VirtualHost>

ProxyPreserveHost On passes the public hostname to the app instead of replacing it with the backend address. This matters for routing, canonical URLs, tenant selection, and host-based security checks. ProxyPassReverse rewrites response redirect headers so that a backend redirect to its private address does not leak that address to visitors.

4. Make the framework proxy-aware

Many frameworks need an explicit trusted-proxy setting before they will use forwarded host or scheme information. Configure that trust according to the framework’s documented rules and restrict it to your Apache proxy or local network. A wrong setting can produce HTTP links on an HTTPS site, redirect loops, or incorrect absolute URLs; trusting every incoming proxy header can allow clients to spoof them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Validate and reload

Run apachectl configtest, reload Apache, and then request the domain. Check the backend directly from the server as well, using its private address and port, to distinguish an application failure from a proxy failure. The vhost access log confirms that Apache received the public request; the error log usually identifies connection refusals, timeouts, or malformed proxy settings.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Add HTTPS without creating redirect loops

HTTPS requires a separate TLS virtual host on port 443 and a certificate whose names cover every hostname you publish. Certificate issuance, storage, renewal, and permissions depend on the certificate workflow and operating environment; Apache’s job is to load the resulting certificate and key and terminate TLS.

1. Create the TLS vhost

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com

    SSLEngine on
    SSLCertificateFile /path/to/fullchain-or-certificate.pem
    SSLCertificateKeyFile /path/to/private-key.pem

    # For a static site:
    DocumentRoot /var/www/example
    <Directory /var/www/example>
        AllowOverride None
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example-ssl-error.log
    CustomLog ${APACHE_LOG_DIR}/example-ssl-access.log combined
</VirtualHost>

For a proxied app, replace the document-root section with the same ProxyPreserveHost, ProxyPass, and ProxyPassReverse directives used by the working HTTP vhost. Ensure the private key is readable by Apache but not broadly readable by ordinary users.

2. Test HTTPS before redirecting HTTP

Confirm that certificate issuance and renewal are working, that port 443 is reachable, and that each certificate name serves the intended vhost. Test with:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -I https://example.com
curl -I https://www.example.com

Only after the TLS vhost works should you redirect port 80. A minimal redirect vhost is:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    Redirect permanent / https://example.com/
</VirtualHost>

Choose the canonical HTTPS hostname deliberately. If both the bare and www names remain valid, list both in the certificate and decide whether the application should preserve the requested host or redirect one name to the other. Do not install an HTTP-to-HTTPS redirect before the HTTPS endpoint is usable, or every visitor will be sent to a broken destination.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Support multiple domains and aliases safely

Each hostname must resolve to the server and be covered by a matching vhost. You can host several names in one vhost with ServerAlias when they intentionally serve the same content, or create separate vhosts when the sites, backends, logs, or security policies differ.

Concern One domain with aliases Several independent domains
DNS Point the apex name and each alias, such as www, to the server. Publish records for every domain; verify that each resolves to the intended server.
Apache names One ServerName plus all required ServerAlias values. Give each site its own ServerName and only the aliases that belong to it.
Fallback risk An omitted alias can land on the first vhost for that address and port. Overlapping names or unexpected file ordering can select the wrong site.
TLS certificate The certificate must include every published alias. Each certificate must cover the names used by its corresponding vhost.
Operations Shared reloads and logs are simple, but a change affects all aliases. Separate logs and configuration reduce cross-site impact and simplify diagnosis.

When adding a vhost, check both port 80 and port 443. An HTTP name can be correct while its HTTPS request selects a different default because the TLS vhost is missing or its ServerName and aliases do not match.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Static files or reverse proxy: choose the right model

Decision point Static DocumentRoot Reverse proxy to an app
Content source Apache reads files from the configured directory. A separate process generates responses on a local or reachable backend.
Apache modules Core HTTP and directory authorization features are sufficient for basic serving. Proxy modules, including the backend protocol module, must be loaded.
Process ownership Deploying files does not require an application process to stay running. A service manager must start, monitor, and restart the backend independently.
Headers and URLs Apache controls the response directly. Preserve the public host and configure the framework to trust the proxy’s forwarded scheme and host information.
HTTPS termination Apache commonly terminates TLS and serves the files. Apache can terminate TLS before forwarding plain HTTP to a private backend, unless end-to-end encryption is required by your design.
Typical failure Wrong path, permissions, or missing index file. Backend is stopped, listening on another address, refusing connections, or generating incorrect redirects.

Diagnose the wrong site, a 404, or a failed proxy

Start with Apache’s parsed map

Run:

apachectl -S

On Windows builds, the equivalent command is commonly httpd.exe -S. The output shows which configuration files Apache parsed, the address-and-port combinations in use, the names assigned to each vhost, and the default for each group. This is the quickest way to detect a file that was never included, a typo in ServerName, or an unexpected vhost taking precedence.

Use a symptom-based check

Symptom Likely cause What to check next
A different site appears DNS points elsewhere, the hostname is not an alias, or the request is selecting the first unmatched vhost. Resolve the name externally, run apachectl -S, and compare the requested name with the vhost’s ServerName and ServerAlias.
Connection times out Port 80 or 443 is blocked by a host firewall, cloud security group, provider rule, or network path. Check listening sockets and inbound rules from outside the server.
Apache returns its default page The custom site is not enabled, the hostname does not match, or the default vhost precedes it. Inspect the parsed map and the distribution’s enabled-configuration mechanism.
Static request returns 403 The directory or a parent directory is not traversable by Apache, or authorization directives deny access. Review filesystem permissions and the matching <Directory> block, then read the vhost error log.
Static request returns 404 DocumentRoot points to the wrong deployment directory or the requested file was not built or copied. Verify the absolute path and inspect the access log for the requested URI.
Proxy returns 502 or 503 The backend is stopped, listening on another address or port, or unreachable from Apache. Test the private backend locally, check its service logs, and read Apache’s proxy error entry.
HTTPS shows the wrong certificate or site The TLS SNI name is not covered, the 443 vhost is missing, or another 443 vhost is first. Run apachectl -S, verify certificate names, and test each hostname separately.
HTTPS redirects repeatedly The app does not trust the proxy’s scheme information or Apache and the app disagree about the canonical URL. Inspect redirect locations, configure trusted proxy headers according to the framework, and keep one clear HTTPS policy.

Read the logs for the matching vhost

The per-vhost access log proves which requests reached Apache and records status codes and paths. The error log contains configuration, permission, TLS, and proxy-connection details. If no entry appears, investigate DNS, the destination IP, and the network firewall before editing Apache rules.

Check DNS from an independent network

Query the public A and AAAA records with an external resolver. An obsolete IPv6 AAAA record can send some visitors to a different server even when the IPv4 A record is correct. Remove or correct records that do not lead to this Apache instance.

A deployment checklist you can reuse

  1. Publish A and, if intentionally supported, AAAA records for the domain and aliases.
  2. Confirm externally that each name resolves to the server’s public address.
  3. Choose DocumentRoot for static files or reverse proxying for a running app.
  4. Create a vhost with an exact ServerName, complete aliases, and separate logs.
  5. For a proxy, load the required modules, bind the backend privately, and configure ProxyPreserveHost, ProxyPass, and ProxyPassReverse.
  6. Run apachectl configtest; fix every error before reloading.
  7. Run apachectl -S and verify the intended vhost is mapped to each address and port.
  8. Reload Apache with the service mechanism supplied by your operating system.
  9. Test every HTTP hostname with curl -I and inspect the matching logs.
  10. Create and test the port-443 TLS vhost, including all certificate names.
  11. After HTTPS works and renewal is confirmed, add the HTTP-to-HTTPS redirect if that is your desired canonical policy.
  12. Recheck firewall rules, backend health, permissions, and logs after the first real deployment.

Final outcome

A reliable Apache domain setup has matching DNS, an unambiguous vhost, and a verified request path. Static content ends at DocumentRoot; a dynamic app continues through the proxy to a supervised private process. Treat port 80 and port 443 as separate matching problems, use apachectl -S to see what Apache actually parsed, and postpone redirects until the destination has been tested end to end.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.