如何直接在 localhost:8080 而不是 tomcat 主页中打开我的 Web 应用程序

How can I open my web application in localhost:8080 directly instead of tomcat home page

如何在 localhost:8080 而不是 tomcat 主页中打开我的 Web 应用程序 例如,我希望 mysite.com:8080/mywebapp 在 mysite.com:8080 中打开 不使用任何反向代理

您可以在没有任何反向代理的情况下完成此任务。当您键入 http://localhost:8080 时,您的网站会打开

Rename the war file to ROOT.war and put it tomcat webapps directory and restart tomcat

,或使用反向代理

  1. 在 tomcat webapps 目录中将您的网站重命名为 ROOT.war

  2. 安装Httpd

  3. 启用在 /etc/httpd/conf/httpd.conf

  4. 中加载 mod_proxy_http.somod_proxy.so
  5. /etc/httpd/conf.d/example.conf下添加名为example.config的文件 并添加如下配置

        <VirtualHost *:8080>
          ServerName exmple.com
          ServerAlias *exmple.com
          ServerAdmin user@gmail.com
          ProxyPreserveHost On
          ProxyRequests off
          AllowEncodedSlashes NoDecode

          <Proxy *>
             Order deny,allow
             Allow from all 
          </Proxy>

          ProxyPass / http://localhost:8080/mywebapp  nocanon
          ProxyPassReverse / http://localhost:8080/mywebapp 

          LogLevel debug
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
        </VirtualHost>