通过域名直接访问Tomcat项目解决方法-笔记

来到这里的小伙伴相信都已经可以在浏览器访问Tomcat,想进入项目的话还需要输入路径

打开Tomcat配置文件 server.xml,从上到下修改

1.修改端口

Tomcat默认端口是8080,把端口改成80,如果不修改的话每次输入域名后面还要加上 :8080,达不到想要的效果

2.修改Engine

把defaultHost=" "里面改成自己的域名

3.修改Host

把Host里的name改成自己的域名

4.在Host 里加入一个Tomcat访问默认路径

假如没有加项目路径,进入域名之后访问的是Tomcat首页,这里docBase里写的是项目名字,相当于自动拼接在了域名后面

5.配置结束,保存关闭

ESC,:wq 保存关闭

以上就是通过域名访问项目的解决办法,希望可以帮到有需要的人

下面附上完整配置

xml 复制代码
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
    maxThreads="150" minSpareThreads="4"/>
-->


<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
           port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
     This connector uses the NIO implementation. The default
     SSLImplementation will depend on the presence of the APR/native
     library and the useOpenSSL attribute of the
     AprLifecycleListener.
     Either JSSE or OpenSSL style configuration may be used regardless of
     the SSLImplementation selected. JSSE style configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true">
    <SSLHostConfig>
        <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
                     type="RSA" />
    </SSLHostConfig>
</Connector>
-->
<!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
     This connector uses the APR/native implementation which always uses
     OpenSSL for TLS.
     Either JSSE or OpenSSL style configuration may be used. OpenSSL style
     configuration is used below.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
           maxThreads="150" SSLEnabled="true" >
    <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
    <SSLHostConfig>
        <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
                     certificateFile="conf/localhost-rsa-cert.pem"
                     certificateChainFile="conf/localhost-rsa-chain.pem"
                     type="RSA" />
    </SSLHostConfig>
</Connector>
-->

<!-- Define an AJP 1.3 Connector on port 8009 -->
<!--
<Connector protocol="AJP/1.3"
           address="::1"
           port="8009"
           redirectPort="8443" />
-->

<!-- An Engine represents the entry point (within Catalina) that processes
     every request.  The Engine implementation for Tomcat stand alone
     analyzes the HTTP headers included with the request, and passes them
     on to the appropriate Host (virtual host).
     Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="www.bigcongming.top">

  <!--For clustering, please take a look at documentation at:
      /docs/cluster-howto.html  (simple how to)
      /docs/config/cluster.html (reference documentation) -->
  <!--
  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
  -->

  <!-- Use the LockOutRealm to prevent attempts to guess user passwords
       via a brute-force attack -->
  <Realm className="org.apache.catalina.realm.LockOutRealm">
    <!-- This Realm uses the UserDatabase configured in the global JNDI
         resources under the key "UserDatabase".  Any edits
         that are performed against this UserDatabase are immediately
         available for use by the Realm.  -->
    <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
           resourceName="UserDatabase"/>
  </Realm>

  <Host name="www.bigcongming.top"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log" suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
		  

<Context docBase="Backstage_management" path="" reloadable="true" />

  </Host>
</Engine>
相关推荐
缘来的精彩2 小时前
Kotlin与Jetpack Compose的详细使用指南
android·kotlin·android studio·compose·viewmodel
Another Iso3 小时前
同时启动俩个tomcat压缩版
java·tomcat
守城小轩3 小时前
Chromium 134 编译指南 - Android 篇:获取源码(五)
android
前期后期3 小时前
Android Lifecycle代码分析:源码分析;为什么使用;注解的方式为什么过期?状态与事件
android·kotlin
每次的天空5 小时前
Android面试总结之GC算法篇
android·算法·面试
仙魁XAN5 小时前
Flutter 学习之旅 之 Flutter 和 Android 原生 实现数据交互的MethodChanel和EventChannel方式的简单整理
android·flutter·flutter module·aar·混合开发·flutter交互
凌云志 !8 小时前
Android Studio 2024版,前进返回按钮丢失解决
android·ide·android studio
tangweiguo030519878 小时前
Android Kotlin 项目完整集成 Bugly 异常监控指南
android·kotlin
Yang-Never8 小时前
Kotlin -> lateinit 和 lazy 详解
android·开发语言·kotlin·android studio
MyhEhud9 小时前
kotlin 过滤 filter 函数的作用和使用场景
android·java·服务器·前端·kotlin