1&1 Web Domain Redirect to Tomcat Instance on DigitalOcean Droplet

April 4, 2015 2.6k views
DigitalOcean DNS Java Apache Ubuntu


I have a DigitalOcean Droplet with a tomcat instance running my Web Application with no issues.

Currently, to access my webapp, I have to go to http://droplet-ip-address:8080/MyWebApp.

I have a Web Domain hosted by 1&1 which is currently redirected to the above address. This means when going to it redirects to http://droplet-ip-address:8080/MyWebApp.

Please could someone tell me whether it is possible to achieve the following:




3 Answers

With your domain hosted at 1&1 (at least on shared hosting) this will likely not be possible unless it is done as a redirect where the URL ends up being the droplet IP. You could however set up something like by doing the following:

1.) In the 1&1 control panel create a DNS record (A Record) pointing to your droplet's IP address.

2.) Now, since your app is running on port 8080 rather than the default web port of 80 we will need to set up a proxy using nginx so traffic is handled on port 80. To do this, first install nginx on your server running Tomcat:

apt-get update
apt-get install nginx

3.) Now open the file /etc/nginx/sites-enabled/default on your droplet in the editor of your choice and change the default Location / block to the following:

location / {
    proxy_pass       http://localhost:8080;
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;

This will tell nginx to relay all requests to your Tomcat instance running on port 8080.

4.) Now restart nginx

service nginx restart

Now, once the DNS change you made in step 1 has propagated your app will be running at the URL:

Mate, thank you very much! Ive been bashing my head for a while trying to figure this one out.

I will try it and let you know how I get on!

Thanks again,

Ben :)

Hello buddy,

Worked a treat! Thank you very much :)

Have another answer? Share your knowledge.