Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk11 min

How to Map a Tomcat Web Application to Your Domain Name

A practical, end-to-end guide to pointing DNS at Apache, proxying a Tomcat context, setting the public host and port, enabling HTTPS, securing the backend, and troubleshooting redirects, 404s, and SNI errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Point your domain’s DNS record to the public server running Apache, define a hostname-based Apache virtual host, and proxy that hostname to Tomcat’s application context. Then set Tomcat’s proxyName and proxyPort to the public host and port. This prevents redirects and absolute links from exposing localhost or an internal port such as 8080.

How the mapping works

A domain name does not point directly to a Tomcat context. The request passes through three layers:

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.
  1. DNS resolves a name such as app.example.com to the public IP address of your reverse-proxy server.
  2. Apache HTTP Server receives the request, selects the virtual host whose ServerName matches the hostname, and forwards the application path.
  3. Tomcat serves the application from its connector, commonly on a private address and port such as 127.0.0.1:8081.

For an application deployed as myapp.war, the normal context path is /myapp. A request for https://app.example.com/myapp/login can therefore be proxied to http://127.0.0.1:8081/myapp/login. Apache’s ProxyPass sends the request; ProxyPassReverse rewrites backend redirect headers so clients continue using the public hostname.

The proxy also gives you one public TLS endpoint, hostname-based routing for several applications, and a way to keep Tomcat’s connector off the public internet. Tomcat’s connector must still know the public identity. Its proxyName and proxyPort values control what servlet calls such as request.getServerName() and request.getServerPort() report to the application.

#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.

Before you change anything

Choose the public hostname and context

  • Use the exact hostname that users will enter, for example app.example.com.
  • Decide whether the application should remain at /myapp or be published at the domain root, /.
  • Identify Tomcat’s connector address and port. The examples below use 127.0.0.1:8081; substitute your actual private listener.
  • Decide where HTTPS terminates. In the usual arrangement, Apache owns the certificate and accepts traffic on port 443, while Tomcat receives plain HTTP on its private network.

Do not assume that a WAR filename and a public URL are interchangeable. A file named myapp.war normally creates the /myapp context. Publishing that application at / requires an intentional root-context deployment, normally using the root application packaging, or a carefully designed proxy mapping.

Step 1: Create the DNS record

At your domain DNS provider, create the provider-appropriate record for app.example.com:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • An A record points the name to the proxy server’s public IPv4 address.
  • An AAAA record points it to a reachable public IPv6 address when IPv6 is configured end to end.
  • Use the equivalent record type if your provider offers a managed alias or another DNS-specific mechanism.

The record must resolve to Apache’s public address, not to Tomcat’s private port. DNS records contain host addresses; they do not encode a destination such as :8081. Record names and screens differ between providers, so use the syntax required by your provider.

Verify the result from a client that can reach the public network:

dig +short app.example.com

For IPv6, check the AAAA result separately. If both A and AAAA records exist, both addresses need to reach the intended proxy; an unusable IPv6 path can make some clients fail even when IPv4 works.

Step 2: Deploy the application at the expected Tomcat context

Place the application on Tomcat and confirm the context path before configuring Apache. With the conventional deployment:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
myapp.war  ->  /myapp

Test the backend locally from the proxy host before introducing DNS or TLS:

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.
curl -I http://127.0.0.1:8081/myapp/

A successful response proves that Tomcat is listening and that the application is deployed at the path you intend to proxy. A 404 here is a Tomcat deployment or context problem, not an Apache virtual-host problem.

If the application is deliberately the site root, make the root context and the public route agree. A proxy that sends / to a backend still mounted at /myapp can produce broken relative links, redirects, or session paths unless the application was designed for that arrangement.

Step 3: Set Tomcat’s public host and port

Edit the HTTP connector in Tomcat’s configuration. The essential attributes when Apache terminates HTTPS are:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<Connector
    port="8081"
    protocol="HTTP/1.1"
    proxyName="app.example.com"
    proxyPort="443" />

Use proxyPort="80" when the public endpoint is HTTP. Keep the connector’s actual port set to the private backend port Apache uses. The connector reference documents that proxyName and proxyPort are intended for Tomcat behind a proxy; they make servlet APIs report the client-facing host and port rather than the internal connection.

This distinction matters for:

  • Absolute links generated by the application.
  • Login, logout, and callback URLs.
  • Redirects that otherwise point to localhost, an internal hostname, or port 8080.
  • Security checks that compare the requested host or port.

Restart or reload Tomcat using the service procedure for your installation, then verify the connector is listening on the expected private address. If Apache and Tomcat are on different machines, use the proxy host’s private address instead of 127.0.0.1 and restrict the connector to that private network.

When HTTPS is terminated at Apache, ensure the proxy and application agree that the original request was secure. Tomcat’s host and port settings provide the public identity; applications that construct URLs from the request scheme may also require the proxy’s standard forwarded-scheme handling or an application-specific trusted-proxy setting. Configure that consistently rather than allowing the backend HTTP connection to force insecure links.

Step 4: Enable Apache’s proxy modules

Apache needs the core proxy module and its HTTP proxy provider. On systems that provide the Debian-style module helper, the common commands are:

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.
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
sudo a2enmod proxy
sudo a2enmod proxy_http

Enable the SSL module as well when Apache will terminate HTTPS. Other operating systems enable modules through their package or configuration system; the required capabilities are still mod_proxy, the HTTP proxy module, and TLS support for an HTTPS virtual host.

Validate the configuration before reloading:

sudo apachectl configtest

Fix every syntax error before applying a reload. A reload keeps existing connections where possible; use your operating system’s normal Apache service command.

Step 5: Create the hostname-based virtual host

HTTP example

The following virtual host publishes the /myapp context through Apache:

<VirtualHost *:80>
    ServerName app.example.com

    ProxyPass        /myapp  http://127.0.0.1:8081/myapp
    ProxyPassReverse /myapp  http://127.0.0.1:8081/myapp
</VirtualHost>

ServerName must be the public hostname, not the backend address. The two proxy paths deliberately use the same context. If your context is different, change both occurrences together. Keep the path boundaries consistent: a rule for /myapp should not accidentally send an unrelated path such as /myapplication to the same backend.

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

After saving the site configuration, enable that virtual host according to your Apache distribution, run apachectl configtest, and reload Apache. If several virtual hosts share the same IP, an incorrect or missing ServerName can send the request to the first matching site and produce the wrong application or a 404.

HTTPS example with Apache as the TLS endpoint

Once a certificate for app.example.com is installed, the TLS virtual host can use the same proxy mapping:

<VirtualHost *:443>
    ServerName app.example.com

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/app.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/app.example.com/privkey.pem

    ProxyPass        /myapp  http://127.0.0.1:8081/myapp
    ProxyPassReverse /myapp  http://127.0.0.1:8081/myapp
</VirtualHost>

The certificate paths above are an example layout; use the paths created by your certificate system. The requested hostname, the certificate name, and Apache’s SSL virtual-host selection must agree. Hostname-based SSL configurations rely on SNI, so a request for a name that does not match the selected SSL host or certificate can fail before Tomcat receives anything.

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.

If you want all HTTP requests to become HTTPS, create a separate port-80 virtual host that redirects to the same hostname. Do not create a redirect that sends users to the internal connector address. After the HTTPS host is working, test both the redirect and generated application links.

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

Step 6: Keep the Tomcat connector private

The reverse proxy is the public entry point. Tomcat should accept traffic only from Apache or from the private network that connects the two servers.

  • Bind the connector to a loopback address when Apache and Tomcat share a host.
  • When they are separate, bind Tomcat to a private interface and allow the proxy host’s private address through the firewall.
  • Do not open the backend port to the entire internet merely because Apache needs access to it.
  • Check cloud security groups, host firewalls, and container port publishing; any one of them can accidentally expose 8081 or 8080.

Apache records the client-facing request, while Tomcat sees the proxied connection. Avoid enabling redundant access logs in both layers unless you need both views for troubleshooting or compliance.

Step 7: Test the complete path

Test in layers so each failure has a clear owner.

  1. DNS: Confirm app.example.com resolves to the proxy’s public address with dig or an equivalent resolver query.
  2. Backend: From the proxy host, request http://127.0.0.1:8081/myapp/ (or the private backend address) and confirm Tomcat returns the application.
  3. Virtual host: Request the public hostname and verify Apache selects the intended site rather than a default virtual host.
  4. Proxy path: Open a page below /myapp, not just the domain root, and check that the response comes from the expected application.
  5. Redirects and links: Sign in, follow a redirect, submit a form, and inspect absolute links. None should expose localhost, the private hostname, or port 8080.
  6. HTTPS: Check that HTTP-to-HTTPS behavior is intentional, the certificate covers the requested name, and the browser reports a valid chain.
  7. SNI: Test the exact hostname users will request. A certificate or SSL virtual-host mismatch can reject the connection before proxying.
  8. Direct backend access: From an external network, confirm the Tomcat port is blocked. Access should work only through Apache.

Useful command-line checks include:

curl -I http://app.example.com/myapp/
curl -I https://app.example.com/myapp/

Run the HTTPS command with the exact public hostname so certificate and SNI selection are tested realistically.

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

Common failures and precise fixes

Redirects point to localhost or port 8080

Tomcat is reporting its internal connector identity to the application. Set proxyName="app.example.com" and set proxyPort to the public port: 443 for HTTPS or 80 for HTTP. Restart Tomcat and repeat a login or redirect test. Also check that the application is not storing an independent public base URL that overrides the request values.

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

A 404 appears at the public URL

First compare the public proxy path and Tomcat context exactly. A request to /myapp must be forwarded to the context that actually exists. Then verify the request selected the correct Apache virtual host. Finally test the backend URL directly from the proxy host; if that is already a 404, fix deployment or context naming in Tomcat.

The wrong application answers

An unmatched hostname can fall through to another virtual host, while an overly broad proxy rule can send several paths to one context. Give each public hostname its own ServerName and keep each ProxyPass mapping specific. Confirm the Host header and the enabled-site order used by your Apache installation.

HTTPS loops or pages contain insecure links

This occurs when Apache terminates TLS but the backend-facing request is treated as ordinary HTTP without preserving the public scheme and port. Keep the public HTTPS virtual host and Tomcat proxyPort="443" aligned, and configure the proxy/application’s trusted forwarded-scheme behavior where required. Test a fresh redirect and inspect the generated URL rather than relying only on the browser’s final page.

Certificate or SNI errors

Check that the browser requested the same hostname configured in ServerName, that the certificate covers that name, and that Apache’s SSL virtual-host selection is correct. Strict SNI matching can reject a request when the hostname does not match the selected SSL configuration. This failure happens at TLS negotiation, so Tomcat logs may contain no corresponding request.

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.

The Tomcat port is reachable from the internet

Inspect the listener address, firewall rules, cloud security groups, and container port mappings. Bind the connector to loopback or a private interface and permit only the proxy network. Re-test from outside the server; a successful public connection to :8081 or :8080 means the isolation is incomplete.

Apache returns a proxy or gateway error

Confirm Tomcat is running, the private address and port in both proxy directives are correct, and local firewall rules allow Apache to connect. Then request the backend directly from the proxy host. A direct backend failure points to Tomcat or networking; a successful backend request with a public failure points to Apache’s virtual host, module, or path configuration.

Choosing the architecture

Architecture TLS termination Backend isolation Hostname routing Static-file handling Operational trade-off
Tomcat exposed directly Tomcat handles the public connection Low; the connector is internet-facing Limited to what Tomcat is configured to serve Tomcat serves the application’s files Fewer components, but less separation and fewer web-server controls
Apache with mod_proxy Apache can terminate HTTPS High when the connector is private Each ServerName can map to a selected context Apache can serve eligible files while proxying dynamic paths Requires module, virtual-host, certificate, and proxy maintenance
Apache with mod_jk Apache can terminate HTTPS High when the connector is private Apache routes according to its worker configuration Useful for deployments that want the web server to serve eligible static content Additional connector and worker configuration compared with the HTTP proxy pattern

The official Tomcat proxy guidance documents mod_proxy as a way to forward a selected application without a separate web connector and identifies mod_jk as an alternative for deployments with different static-content requirements. For a straightforward domain-to-context mapping, the HTTP proxy directives are usually the smallest configuration.

Mapping several applications and domains

Repeat the same pattern per hostname and context. For example, one virtual host can map app.example.com/myapp to the /myapp context, while another hostname maps a different path and connector. Give every public hostname a matching certificate when HTTPS is used. Keep the backend ports private even when several applications share one Tomcat installation.

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

Do not copy a working block and change only the domain name while leaving the old ProxyPass target. The most common multi-application mistake is a correct DNS record combined with a virtual host that still forwards to the previous context.

Configuration checklist

  • DNS A and/or AAAA records resolve the public hostname to Apache.
  • The WAR is deployed at the context used in both proxy directives.
  • mod_proxy and the HTTP proxy module are enabled.
  • ServerName exactly matches the public hostname.
  • ProxyPass and ProxyPassReverse point to the same intended context and backend port.
  • Tomcat has proxyName set to the public hostname.
  • Tomcat has proxyPort set to 80 or 443, matching the public endpoint.
  • Apache’s certificate and SNI configuration match the requested hostname.
  • The backend listener and firewall allow only the proxy network.
  • DNS, virtual-host selection, application pages, redirects, sessions, absolute links, TLS, and direct-port blocking have all been tested.

What success looks like

A user enters https://app.example.com/myapp. DNS sends the request to Apache; Apache selects the app.example.com TLS virtual host and forwards /myapp to Tomcat’s private connector. Tomcat reports app.example.com and public port 443 to the application, so redirects and absolute URLs stay on the public HTTPS address. The user never needs to know that the application is running on 127.0.0.1:8081, and the backend port is not directly exposed.

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
Crashes, No Sound, or Screen Glitches?Free driver scan

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.