Deployed a java web application. Not able to access the application via the IP address.

November 16, 2014 4.8k views

I created a Ubuntu 14.04 droplet, and installed tomcat.
My droplet's ip address(from the mail i recieved) is say for example : IP_address.

After that i installed a web application using this tutorial :https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-7-on-ubuntu-14-04-via-apt-get.

I am able to access my application using http://IP_address:8080/myapplication.

Also, I have have connected the IP_address to my domain name using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean.

i.e i have mydomainname.com pointing to IP_address.

Ping from my local system to the domain name gives me a reply mentioning the IP_address.

But when i try to access http://IP_address, my browser just says "This webpage is not available".

Any help on this would be useful.
Thanks in advance.

1 Answer

Browsing to http://IP_address doesn't work because there is nothing listening on port 80 (tomcat is listening on 8080). I would recommend installing nginx and configuring it a reverse proxy so that it forwards requests from port 80 to port 8080.

Run the following command:

sudo apt-get install nginx

Then, edit /etc/nginx/sites-enabled/default and replace its contents with the following:

upstream tomcat {
    server http://localhost:8080;

server {
    listen 80;
    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://tomcat;

Finally, restart nginx:

sudo service nginx restart
Have another answer? Share your knowledge.