You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在多个URL上使用同一Tomcat实例?配置问题求助

Troubleshooting quietude.anotherdomain.com Access Issue with Tomcat & Apache

Hey there, let's break down why your new domain quietude.anotherdomain.com isn't working while opxxx01.domain.com runs perfectly. Based on your environment details (RHEL 7.4, Tomcat 8.5.30, Apache 2.4.6) and the config you shared, here are the key checks and fixes to get this sorted:

1. Verify DNS & Network Reachability

First, rule out basic network issues:

  • Run nslookup quietude.anotherdomain.com or dig quietude.anotherdomain.com on your local machine or the server itself. Make sure the returned IP matches your server opxxx01's public/private IP. If not, you'll need to update the DNS record for quietude.anotherdomain.com to point to the correct IP.
  • Check your server's firewall (either firewalld or iptables) to ensure the ports used for access (80/443 for Apache, or 8080 for direct Tomcat access) are open. For example, with firewalld:
    sudo firewall-cmd --add-port=80/tcp --permanent
    sudo firewall-cmd --reload
    

2. Fix Apache Reverse Proxy Configuration

Since you have Apache 2.4.6 running, it's likely you're using it as a reverse proxy to Tomcat (direct Tomcat access on 8080 isn't typical for production). You need to add a VirtualHost for your new domain to forward requests to Tomcat:

  • Create or edit an Apache config file (e.g., /etc/httpd/conf.d/quietude.conf) with this content:
    <VirtualHost *:80>
        ServerName quietude.anotherdomain.com
        # Forward all requests to Tomcat's port (adjust if you use a different port)
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/
        # Optional: Logs for the new domain
        ErrorLog /var/log/httpd/quietude_error.log
        CustomLog /var/log/httpd/quietude_access.log combined
    </VirtualHost>
    
  • Enable required Apache modules (if not already enabled):
    sudo yum install httpd-mod_proxy httpd-mod_proxy_http
    sudo systemctl restart httpd
    
  • Confirm your original domain opxxx01.domain.com has a similar VirtualHost setup—this ensures consistency in how Apache handles both domains.

3. Tweak Tomcat Host & Connector Settings

Your Tomcat Host config looks mostly right, but let's check a few details:

  • In your server.xml, ensure the Connector element isn't bound to a specific IP. The address attribute should be set to 0.0.0.0 or omitted entirely, so Tomcat accepts requests from all sources (including Apache):
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               address="0.0.0.0" />
    
  • If your app is deployed under a specific context (not the ROOT app), you can add a Context entry to your new Host to set it as the default:
    <Host name="quietude.anotherdomain.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="quietude_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b %S %D %F" />
      <Context path="" docBase="your-app-folder" reloadable="true" />
    </Host>
    
  • Check Tomcat logs (logs/quietude_access_log*.txt and logs/catalina.out) to see if requests are reaching Tomcat. If logs show no incoming requests, the issue is upstream (DNS/Apache). If there are errors, the log details will point to the root cause (e.g., missing app deployment).

4. Test with Local Hosts File (For Debugging)

If you're testing in a non-production environment, bypass DNS to isolate the issue:

  • On your local machine, edit the hosts file:
    • Windows: C:\Windows\System32\drivers\etc\hosts
    • Linux/macOS: /etc/hosts
  • Add a line like:
    [your-server-ip] quietude.anotherdomain.com
    
  • Try accessing quietude.anotherdomain.com again—if it works, the problem is with your DNS record.

内容的提问来源于stack exchange,提问作者Jeremy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:47:06