Score:0

How to set up DNS on google domains to host tomcat websites on the internet

us flag

Excpectations / Target

  • We have a domain as (say) example.com bought on Google Domains and a PC running with windows 10 Pro
  • We intend to make this PC a server for hosting 2 of our web-apps app1 and app2 Currently we do not own a static IP address so lets refer the public address as: 192.0.2.0
  • Web-applications app1 and app2 are running on tomcat in separate app-bases and port 8081 & 8082
  • We want to run app1 and app2 on the subdomains app1.example.com and app2.example.com respectively.

Here are all the things that are working:

  1. the web-applications running on the separate app-base in tomcat (v9) on separate ports and are accessible locally and from intranet.
  2. the web-applications are also accessible from the internet with successful port forwarding (192.0.2.0:8081 and 192.0.2.0:8082 successfully load app1 and app2 respectively).

Problem: URL domain gets replaced with public IP address:

Now that the port forwarding was successful I tried domain forwarding (before reading much about how DNS configuration is supposed to be done).

This is how I did domain forwarding:

  1. I went in the website section (website_section_cropped_screen_shot.png), there clicked on Add a forwarding address(Add_a_forwarding_address_SS_cropped.png).
  2. Then in the resulting form, the filled the text-boxes labeled Forward From and Forward to with app1.example.com and 192.0.2.0:8081 respectively.

Now after doing this the address app1.example.com would redirect to app1 but the URL would would replace app1.example.com with 192.0.2.0:8081

Then, I read many articles and blogs telling to add an A type record or a CNAME type record but I could not understand how should I do it or what are the combination of records needed to make it work properly.

I tried the combination (in the Domain section):

Combination 1:

{ hostname=example.com, type=A, TTL=3600, Data:192.0.2.0 }
{ hostname=app1.example.com, type=CNAME, TTL=3600, Data:192.0.2.0:8081 }

Combination 2:

{ hostname=app1.example.com, type=TXT, TTL=3600, Data:192.0.2.0:8081 }

But none worked and later it stopped making sense to me.

Please help me with this I do not have any experience in setting up DNS for a website and/or whatever else is needed to meet the above mentioned expectations.

UPDATE


Thanks to @fvu I was able to get started with nginx, configured it locally which is working and got the hang of how proxy server work(well the best case scenarios only)

Now there is another problem, I am not able to successfully open the port 80 on the server machine.

I tried and tested everything:

  • the nginx successfully starts and work on port 80 implying 80 not blocked by any other process.
  • all other ports are properly being port forwarded but the port 80 is not shown open checked on many port checker sites(mostly on portchecker.co)
  • to check what is happening I edited firewall settings to add rules and start logging ALLOWED as well as DENIED packets for all profiles(domain, public and private)
    • in the logs I saw that there were some requests for 443 port. I suspect if the request in port 80 is somehow being converted to 443 but do not know for sure. IS IT POSSIBLE?
    • there were many requests on port 80 that were allowed but still port 80 is shown to be closed on portchecker sites

Now I will either have to fix the port-80-not-opening issue or change the nginx port to something else than 80

But if the port is changed I will be needed to be mentioned somewhere like in the DNS records or so.. which is a bit unclear to me.

I was thinking maybe in router I could forward port 80 to 81 and have nginx run on 81 or so. but I need to try that out yet.

Meanwhile if you could tell me something about what is the way to manage reverse proxy using nginx running on port other than 80.

[AM IN HURRY SO MAY CONTAIN TYPOS OR LESS DETAIL. PLEASE ASK IF NEEDED!]

Score:0
al flag
fvu

As you don't own a static ip address for the server you will have to make a detour via one of the dynamic dns providers (maybe google domains already implements such a service, don't know).

THEN you will be able to CNAME that name to app1.example.com AND app2.example.com (two CNAME records to be clear!!!). You cannot specify a port in a CNAME record (see here for a related question).

At this point you will be capable of publishing the addresses of your services but you will always have to specify the port number with it, which can be annoying.

Now, to get rid of custom ports while being capable of running two services on one address two hostnames point at, use a reverse proxy that supports SNI in front of your Tomcats. I like nginx, before we used pound which is easier to set up for simple configurations but there are plenty of others to choose from. Or, run both services in one Tomcat and use Tomcat's built-in SNI support.

There are indeed many steps (and auxilliary stuff to set up) to make this kind of setups work, I hope my explanation about makes enough sense to get you going.

Ameya Kalyankar avatar
us flag
first of all sorry I could not reply to this very soon I was caught in some other tasks! Now about your answer, we do intend to buy a static ip in the near future so in that context I had to ask: say for a time period if the server device is made sure to have the same Public IP address and If I skip the dynamic dns step in the hosting setup will the hosting work for that period of time. **PURPOSE OF QUESTION**: if the setup process works by skipping the dynamic dns step as long as the Public IP is the same as when setup was done then I can just start with the **to be continued...**
Ameya Kalyankar avatar
us flag
... then I can just start with the rest of the steps. If not we will first make sure to buy the static IP and then proceed with the rest of the steps. @fvu
fvu avatar
al flag
fvu
That's correct. Good luck, and don't forget to upvote and accept if you feel that my reply has solved your problem!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.