3
kruf13
3y

Sorry for my noob question. Too scared to post in stackoverflow.
I have a domain for my website from namecheap.my website is made with springboot and hosted on my homeserver port 80
I pointed my domain to publicip:80.never works fine except when i put my domain name in the address bar it redirected to my ip and shows the ip in the address bar.
Am I missing any steps?do i need to do something in my embedded tomcat server?

Comments
  • 0
    If it's a home internet connection it's one of many things, probably at the least your router is blocking inbound requests. Home internet connections aren't great for hosting.

    But anyway, look at aws free tier, it's free!
  • 2
    If it's hosted in your home, you need to port forward the servers' port in your router config.
  • 1
    Aaaaand welcome!
  • 0
    @ArcaneEye i already port forwarded.my website loads just fine.the only problem is instead of domain name it shows my ip in the address bar
  • 1
    Mhm you might wanna look into DNS Setup.
    Don't take my word for it, Just a hunch.

    Anyway people, THAT'S HOW YOU ASK QUESTIONS!

    Welcome to devRant mate!
  • 0
    I remember have some "protections" against domains that resolve in local addresses. So i would try to see what is actually resolved, when you look up your domain.
  • 3
    "I pointed my domain to publicip:80"

    What does this mean? I suspect this is the issue. If you had a proper name record in the DNS, this shouldn't happen.

    but it seems like you're using a redirect that goes domain.name -> ip:80 (some sort of redirect)

    instead you should have

    domain.name == ip:80 (DNS A record)

    how do you have your DNS setup? Is the record already updated if you use "ping"? Is it an A record?
  • 5
    Strap the domain to cloudflare with NS records.

    On cloudflare route www and @ to your public IP using the A record type this will mask the fact your HOME NETWORK is now open to the public.

    This will also give you a free firewall you WILL need to configure once bots start bashing your internet traffic.

    On your router accept port 80 connections and forward traffic / run a virtual server (depends on router) to internalIP :80

    On device running website, setup a virtualhost to accept "www.myDomain.com" on port 80

    So to repeat:

    Namecheap: add NS records for cloudflare

    Cloudflare: add A name records to publicIP

    Router: open port 80 and forward traffic to internal IP on port 80

    Server: setup virtualhost for domain not IP
    ---

    Once your that far, swap :80 for :443 and spin up certbot to issue ssl certificates.

    If you have a static IP (doesn't change) then set this and forgot, otherwise if you have a dynamic IP you'll need to look into cloudflare a API to setup an automatic updater for the A records so when your IP changes the DNS records will follow you.

    If that doesn't work, then your public IP may not be YOUR public IP but a ISP NAT otherwise your ISP maybe blocking inbound ports in which case your up shit creak and need to grab a paid / free host to do this.

    Also check your ISP's fair use policy's to ensure your actually allowed to run a public web server over your ISPs connection - not all allow this and a lot will block it by default.
  • 0
    @Hazarth it does not accept ip number with with port as a record.so yeah I have to redirected it
  • 1
    @kruf13 That's correct though. DNS resolves domain names to IPs, not to host which is a subtle but important distinction.

    What is usually done to work with this is to host a reverse proxy like nginx or apache on the default ports for http/https traffic (80 and 443 respectively), have those check the Host header and then forward the requests internally to the actual server handling the requests (so your Spring Boot applicaiton) which can then run on any port (you can configure the reverse proxy to forward the requests anywhere you want, really).

    That way the user doesn't have to go the extra mile to remember some port numbers, you can run your actual application on any port you want and expose it through the standard ports using a rather slim adapter (nginx is at least to my knowledge, not too sure about apache) which in turn allows you to use DNS properly (by configuring a mapping from host to IP so the browser knows what mydomain.com means).
  • 2
    "Too scared to post it to Stackoverflow" well this good decision, because Stackoverflow people there are toxic and will screaming at you.
  • 0
  • 0
    @johnmelodyme kind of same community but they are toxic there
Add Comment