7

I have a Tomcat Server where a .war file is running.

I can run the .war file when typing localhost:8080/.. in the browser.

But I have to reach this .war file over network. So I have a external IP with a domain name on it.

And i should reach this .war file when typing xx.xxx.xxx.xxx:8080/.. in browser.

So this IP address should point to its localhost and further to the .war file.

How can I achieve this?

12
  • so you want to access the app in your local network or via internet Commented Jan 23, 2014 at 9:23
  • Port 8080 is open on firewall?
    – MariuszS
    Commented Jan 23, 2014 at 9:23
  • 1
    Wait, where do you have this public IP? Are you sure that you have it assigned to you server? If not, then you must enable port forwarding on your router or dmz etc
    – Mr. P
    Commented Jan 23, 2014 at 9:27
  • 1
    Sory for myself-respond but, only if your server has public IP assigned, you can consider firewall blocking or tomcat bind address changing.
    – Mr. P
    Commented Jan 23, 2014 at 9:29
  • 1
    @JqueryLearner, fisrt of all check if your server does have a external IP assigned. If yes, it is highly probable you are able to access it already as Tomcat is listening on all IPs possible. If, however, you do not have a public IP, but your router has, you have to enable port forwarding on it to your server (something like: incoming 8080 to 192.168.1.2 port 8080 depending on your LAN ip of the server)
    – Mr. P
    Commented Jan 23, 2014 at 10:14

4 Answers 4

8

Basically you configure your connector with the optional "address" attribute containing the ip address that you want to bind to.

tomcat/conf/server.xml

    <Connector 
        port="8080" 
        protocol="HTTP/1.1" 
        address="xxx.xxx.xxx.xxx"
        connectionTimeout="20000" 
        redirectPort="8443" 
      />

Information available at Tomcat homepage http://tomcat.apache.org/tomcat-7.0-doc/config/http.html and http://wiki.apache.org/tomcat/FAQ/Connectors#Q6.

2

If the external IP you have is assigned to WAN of your router, you'll have to set up port-forwarding or DMZ to your server using your routers admin panel. It's different for each brand, so you'll have to look it up for yours.

0

Tomcat by default is listening on all IP addresses.

Check your firewall or router. This is network/routing problem, not related with Tomcat configuration.

address : For servers with more than one IP address, this attribute specifies which address will be used for listening on the specified port. By default, this port will be used on all IP addresses associated with the server.

http://tomcat.apache.org/tomcat-7.0-doc/config/http.html


  1. Check if your IP is binded to tomcat server.

  2. Check if port is open

    telnet xx.xxx.xxx.xxx 8080
    
0
0

Maybe it will be easier to change tomcat port from 8080 to 80. A lot of firewalls allows only port 80. You can see how to change it here: How to change the port of Tomcat from 8080 to 80?

6
  • if i do this, i cant start the tomcat anymore
    – silvia_aut
    Commented Jan 23, 2014 at 9:33
  • Probably port 80 is already taken.
    – MariuszS
    Commented Jan 23, 2014 at 9:34
  • 1
    Btw, the question was about And i should reach this .war file when typing xx.xxx.xxx.xxx:8080/.., so why 80?
    – MariuszS
    Commented Jan 23, 2014 at 9:52
  • 1
    @AshotKarakhanyan, if you do not provide a answer but a proposal, consider adding a comment
    – Mr. P
    Commented Jan 23, 2014 at 10:10
  • 1
    @Pisak, my answer is possible solution, because I had such situation, when only port 80 is allowed. Yes, it was be better to add comment but for it I needed 50 reputation(I don't have it yet), so I added a answer which possibly can help. So it was better to not answer anyway? Commented Jan 25, 2014 at 7:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.