简体   繁体   中英

How to change the IP address and Port number of Tomcat to some url

I am new to web development. I have created a flex based website and now i want to deploy it in my tomcat server. I want to change the URL from http://localhost:8080/myapp/ to http://myapp/

Please let me know if somebody has done something similar.

Thanks, Aj

You can do that through:

  • Setting on your router NAT (which can map request to certain IP:port to other IP:port), or
  • Setting on your domain name server (be it local or global), or
  • Adding a reverse proxy server that can do the translation, this way eg
    • Apache Web Server + mod_proxy
    • Apache Web Server + mod_jk
    • Apache Web Server + mod_rewrite
    • IIS + ISAPI
    • nginx
    • Varnish

I'd recommend the 3rd approach, as you don't usually want to expose your Tomcat directly on production.

You need to change the listen port of the HttpConnector in conf/server.xml:

<Connector port="80" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

Note that giving no port in the URL means port 80, which on Unixoids (like Linux) means that the task that opens the port must run as root .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM