Halloween 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 PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Map a Tomcat Web Application to Your Domain Name

A practical guide to pointing DNS at Apache, forwarding a Tomcat context with ProxyPass, configuring public host and port values, securing the backend, and troubleshooting redirects, 404s, HTTPS loops and SNI errors.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Point your domain’s DNS record at the public server running Apache, create an Apache virtual host for that hostname, and proxy the application’s Tomcat context to its private connector port. Then set Tomcat’s proxyName and proxyPort to the public host and port. This combination makes URLs, redirects, cookies and servlet APIs use app.example.com instead of an internal address such as localhost:8080.

What the finished setup looks like

A browser should never need to know that Tomcat is listening on an internal port. The request path is:

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. The visitor requests https://app.example.com/myapp.
  2. DNS resolves app.example.com to the public address of your reverse-proxy server.
  3. Apache selects the virtual host whose ServerName is app.example.com.
  4. Apache forwards the /myapp path to Tomcat, for example at http://127.0.0.1:8081/myapp.
  5. Tomcat serves the application and generates links and redirects using the public hostname and port configured on its connector.

In this design, Apache is the public HTTP or HTTPS endpoint and Tomcat is a backend service. The proxy can route several domains or applications while keeping the Tomcat port off the internet.

Before you change anything

Identify the four names and ports

  • Public hostname: the exact name visitors will enter, such as app.example.com.
  • Public port: normally 443 for HTTPS or 80 for HTTP.
  • Tomcat context: the path under which the application is deployed, such as /myapp.
  • Backend connector: the address and port Apache can reach, such as 127.0.0.1:8081.

Keep these values consistent. A domain can resolve correctly and Apache can be running correctly, yet the application still returns a 404 if the proxy path and Tomcat context differ.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • 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.

Confirm the deployment context

A WAR named myapp.war normally creates the /myapp context. A file named ROOT.war creates the root context, which is requested as /. Use the root context only when the public route and the application packaging are deliberately designed to match it. Do not assume that a WAR called myapp.war is available at the domain root.

Decide where TLS terminates

If Apache owns the certificate and accepts HTTPS, set Tomcat’s public port to 443, even though Apache talks to Tomcat over HTTP on the private network. If you expose only HTTP, use public port 80. The public scheme and port must be reflected in the connector settings and in any application or framework settings that build absolute URLs.

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

Step 1: Point DNS at the reverse-proxy server

Create the record required by your DNS provider for the hostname. An A record maps the name to an IPv4 address; an AAAA record maps it to an IPv6 address. Some providers offer an equivalent alias record. The record must resolve to the public address where Apache is listening, not directly to the private Tomcat address.

  • Use the exact hostname you will place in Apache’s ServerName.
  • If the host has both IPv4 and IPv6 connectivity, configure both records only when Apache and the firewall are ready to accept traffic on both.
  • Check the result with your provider’s DNS tools or a command such as dig app.example.com A and dig app.example.com AAAA.

DNS changes may be cached according to the record’s TTL. Test against the address currently returned by DNS before diagnosing Apache or Tomcat.

Step 2: Enable Apache’s proxy modules

Apache needs the core proxy module and the HTTP proxy module to forward ordinary HTTP requests. On systems that provide the Debian-style module utility, the commands are:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo systemctl restart apache2

On other distributions, enable the equivalent modules in the Apache configuration and reload the service using that distribution’s service name. Verify that Apache starts cleanly before adding the virtual host. A syntax check such as apachectl configtest should report Syntax OK.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • 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

If Apache terminates HTTPS, also enable the SSL module and configure the certificate for the virtual host. The certificate’s names must include the hostname visitors request.

Step 3: Create a hostname-based virtual host

HTTP example

The following virtual host accepts the public name and forwards only the application context. Replace the hostname, context and backend port with your values:

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

    ProxyPass        /myapp http://127.0.0.1:8081/myapp
    ProxyPassReverse /myapp http://127.0.0.1:8081/myapp

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

ProxyPass sends requests under /myapp to the same context on Tomcat. ProxyPassReverse rewrites redirect headers returned by the backend so that clients continue to use the public URL. Keep the path on both sides aligned unless you have a deliberate path translation plan.

HTTPS example

When Apache is the HTTPS endpoint, put the proxy directives in the SSL virtual host and configure the certificate there:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<VirtualHost *:443>
    ServerName app.example.com
    SSLEngine on
    SSLCertificateFile /path/to/fullchain.pem
    SSLCertificateKeyFile /path/to/private-key.pem

    ProxyPass        /myapp http://127.0.0.1:8081/myapp
    ProxyPassReverse /myapp http://127.0.0.1:8081/myapp

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

The certificate paths above are examples, not universal filesystem locations. Use the paths supplied by your certificate-management process. If you also keep an HTTP virtual host, make its behavior explicit: serve HTTP, redirect it to HTTPS, or proxy it separately. Do not create an accidental redirect loop.

Enable and select the virtual host

On Debian-style installations, save the configuration as a site file, enable it, and reload Apache:

Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • 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)
sudo a2ensite app.example.com.conf
sudo apachectl configtest
sudo systemctl reload apache2

On any platform, inspect the active virtual-host map if a request appears to reach the wrong site. A request can resolve to the right server but still match Apache’s first default virtual host when the ServerName or ServerAlias is missing or misspelled.

Step 4: Tell Tomcat the public identity

Tomcat’s HTTP connector has proxyName and proxyPort attributes specifically for operation behind a proxy. They affect values such as request.getServerName() and request.getServerPort(), which servlet applications use when constructing absolute URLs.

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

Edit the connector in Tomcat’s server.xml. For an HTTPS site whose TLS terminates at Apache, the relevant portion is:

<Connector port="8081"
           protocol="HTTP/1.1"
           proxyName="app.example.com"
           proxyPort="443" />

For a public HTTP site, use proxyPort="80". The connector’s actual port remains the private backend port that Apache uses. Do not change it to 443 merely because the public site uses HTTPS.

Applications that need to know the original scheme may also require the connector’s scheme and secure attributes or an application-aware forwarded-protocol configuration. Configure those only according to how your framework consumes proxy headers; setting a public port alone does not make every framework trust arbitrary client-supplied headers.

Restart or reload Tomcat after changing the connector, then watch its logs for XML errors or a failure to bind the connector. A malformed connector can prevent Tomcat from starting, so retain a known-good copy of the file while editing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • 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

Step 5: Protect the Tomcat connector

The backend port should not be a second public entry point. Bind it to loopback when Apache runs on the same machine, or restrict it with a firewall to the proxy server’s private address or network.

  • Use 127.0.0.1 or the appropriate private interface for a single-host deployment.
  • Permit the Tomcat port from the reverse-proxy host only when Apache and Tomcat are on separate machines.
  • Block unsolicited internet traffic to the backend port at the host or network firewall.
  • Keep administrative Tomcat ports and management applications protected separately.

Apache records proxied requests, so review whether duplicate Tomcat access logging is useful for your operations. Keep the logs that provide the audit and troubleshooting detail you need, but avoid paying the storage and processing cost of identical records without a purpose.

Step 6: Test the mapping in layers

Test DNS and the selected virtual host

  1. Resolve the hostname and confirm it returns the reverse-proxy address.
  2. From a client that reaches the server, request the hostname rather than the server’s raw IP. Hostname matching is part of the test.
  3. Inspect Apache’s access log while making the request. If no entry appears, investigate DNS, routing, firewall rules or the listener.

Test the backend independently

From the proxy host, request the Tomcat endpoint directly:

curl -i http://127.0.0.1:8081/myapp

This isolates Tomcat and the application from DNS and Apache. A failure here is not fixed by changing ProxyPass; check that Tomcat is running, that the context deployed, and that the connector is listening on the expected address and port.

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.

Test the public URL

curl -i https://app.example.com/myapp

Check the status code, the Location header on redirects, links in the returned HTML, login callbacks and session behavior. Absolute links should use the public hostname and intended scheme rather than localhost, an internal IP address or port 8080.

Test certificates and SNI

Connect using the real hostname, not only the server IP, and verify that the certificate presented is valid for that name. Hostname-based SSL configurations and strict Server Name Indication matching must agree with the requested host. If the name does not match the selected SSL host configuration or certificate, the request can be rejected before it reaches Tomcat.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How the two proxy directives differ

Directive Purpose Typical value
ProxyPass Forwards an incoming path to a backend URL. /myapp http://127.0.0.1:8081/myapp
ProxyPassReverse Rewrites backend redirect headers so clients continue to use the public URL. /myapp http://127.0.0.1:8081/myapp
ServerName Selects the hostname-based virtual host. app.example.com
proxyName Supplies Tomcat’s public server name to servlet APIs. app.example.com
proxyPort Supplies Tomcat’s public server port to servlet APIs. 443 for a TLS-terminated site

ProxyPassReverse does not replace proxyName and proxyPort. The former handles response headers at Apache; the latter makes Tomcat and the application aware of the public identity when they generate URLs themselves.

Direct Tomcat exposure or a reverse proxy?

Concern Direct Tomcat exposure Apache reverse proxy
TLS termination Tomcat handles the public certificate and HTTPS connection. Apache can terminate TLS and forward privately to Tomcat.
Backend isolation The Tomcat listener is reachable wherever the firewall permits it. The Tomcat port can be limited to loopback or the proxy network.
Multiple hostnames Requires careful Tomcat host and connector configuration. Apache virtual hosts route names before forwarding.
Static files Tomcat serves them with the application. Apache can serve eligible static content directly; the documented alternative, mod_jk, is also used in deployments that want the web server to serve selected static files.
Logging Tomcat is the primary access-log source. Apache logs the client-facing request and Tomcat can log backend activity, potentially duplicating records.
Operational complexity Fewer moving parts, but fewer routing and isolation options. More configuration and certificates to maintain, with clearer separation between public and application tiers.

For one internal application on a trusted network, direct Tomcat can be simpler. A public domain, HTTPS, several applications or a requirement to hide backend ports generally favors a reverse proxy. The choice is architectural; it does not remove the need to set Tomcat’s public identity correctly.

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

Common failures and precise fixes

Redirects go to localhost, an internal address or port 8080

This means Tomcat or the application is deriving its URL from the backend connection. Set proxyName to the public hostname and proxyPort to the public port on the connector, then restart Tomcat. Check whether the application has its own canonical base-URL setting that overrides servlet values.

The domain returns 404 or the wrong application

Compare the public path, the left side of ProxyPass, and the deployed Tomcat context character for character. Then verify that the request matched the intended virtual host. A request sent to a default host can produce a convincing but unrelated 404.

HTTPS loops or links downgrade to HTTP

Ensure Apache terminates TLS in the virtual host that handles the requested name and that Tomcat’s public port is 443. If the application needs the original scheme, configure the framework’s documented proxy or forwarded-header handling rather than trusting arbitrary headers. Remove conflicting HTTP-to-HTTPS redirects from layers that do not know the public scheme.

The certificate is wrong or SNI is rejected

Use the hostname in the request, confirm that the certificate covers it, and check that Apache’s SSL virtual host uses the same name. Strict SNI matching can reject a request when the requested name and selected SSL host do not agree.

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.

Apache cannot connect to Tomcat

Test the backend URL from the proxy host with curl. Check that Tomcat is listening on the configured port, that the address is reachable from Apache, and that a local firewall is not blocking it. A loopback address on one machine is not reachable from a proxy on another machine; use the private address in that arrangement and restrict access with firewall rules.

The backend is still publicly reachable

Scan the server’s listening interfaces and firewall rules, then bind or filter the connector so only the proxy network can reach it. Do not treat an obscure port as protection.

Operational checklist

  • DNS resolves the exact public hostname to the reverse-proxy address.
  • Apache has the proxy and HTTP proxy modules enabled.
  • The virtual host’s ServerName exactly matches the requested hostname.
  • The HTTPS certificate and SNI configuration cover that hostname.
  • ProxyPass and ProxyPassReverse use the intended context and backend port.
  • The WAR name and deployed Tomcat context match the public path.
  • Tomcat’s proxyName is the public hostname and proxyPort is 80 or 443 as appropriate.
  • The backend connector is restricted to the proxy host or private network.
  • Public tests cover pages, redirects, login/session callbacks and absolute links.
  • Apache and Tomcat logs are retained intentionally, without unexplained duplicate access records.

When to use the root context

Mapping / to a root deployment is appropriate when the application is packaged as ROOT.war or otherwise deployed as Tomcat’s root context and the domain should open directly to it. If the application remains /myapp, do not hide that path with an unrelated proxy rewrite unless you have tested links, redirects, cookies and static resources. Context-aware applications often embed their context path in generated URLs.

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.

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

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.