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:
- the web-applications running on the separate app-base in tomcat (v9) on separate ports and are accessible locally and from intranet.
- 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:
- 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).
- 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!]