I'm trying to deploy a JS app (back in nodejs, front in reactjs) on a hosting server. I've dockerized everything (back, front and database) and everything works well, I can access my app through the IP address of the server.
Now I'm trying to setup a domain name to point to my app.
I've a Invalid Host header when I try to access from domain name (while still working accessing through server's IP address).
I've tried to add a HOST:mydomain.com to the .env of my reactjs app but I got this error Could not find an open port at mydomain.com
Would love if someone can help me through this :)
Given app works by IP, you can leave config of app as is. Do not add HOST or any other config.
IP to name mapping is done using DNS. So made DNS registration in DNS zone like this
mydomain.com A <IP address of app>
Where A is DNS entry type. Or made request to provider to register A entry type for you.
For testing purposes you may do mapping on any Windows PS using hosts file C:\Windows\System32\drivers\etc\hosts where mapping is done by
<IP address of app> mydomain.com
hosts works on one PC only.
After adding to hosts or to DNS try ping mydomain.com to make sure that name is resolved to correct IP address.
Mapping on web server is done when one web server hosts several different sites on one IP. But when you use Docker it's best to have one Docker container for one service.
Related
I've created a node.js app. When it runs my mobile phone can connect to it using address 192.168.1.5. In other words, when I open a browser on my phone and enter 192.168.1.5 I get a welcome page served by the app running on my PC.
The problem is that the IP address is not human friendly. Is there a way to access my app by an alias? For example, http://myapp or something like this?
Yes, these aliases are provided by the domain name service (DNS). You need to set up a hostname on DNS to point to your machine's local address.
Put that IP address into a DNS server.
Here's a free way to do that.
Create a FreeDNS account by visiting https://freedns.afraid.org/
Click on Subdomains.
Click the Add link.
Create a subdomain hostname under one of FreeDNS's public domains. Maybe mydev.manidos.mooo.com is a good choice
Put your machine's IP address into it.
Then, use https://mydev.manidos.mooo.com to hit your development machine's nodejs app.
You can pay FreeDNS to register your own domain name and use that if you prefer.
There are all sorts of other ways to register a domain and then add address records to it, to translate from hostnames to IP addresses.
Edit If you were connecting to and from your desktop / laptop machine, you could add a hostname to your hosts file. The hosts file is itself a little DNS registry that's local to your machine. On windows it's at C:\Windows\System32\drivers\etc\hosts. On *nix and mac it's at /etc/hosts.
But, you are connecting to your app from a mobile device. Editing the hosts file in a mobile device is unreasonably difficult.
I've attempted to set up a test binding through IIS to localtest.me, but it's not resolving to my local IP address. My understanding of localtest.me is that it should resolve automatically. In Chrome is get the error message:
blog-test.localtest.meβs server IP address could not be found.
And when pinging blog-test.localtest.me I get the following error:
Ping request could not find host blog-test.localtest.me. Please check the name and try again.
In IIS I have a site that's bound to blog-test.localtest.me with the following settings:
Everything I've read online advises that localtest.me should resolve automatically? Is this the case or is there setup step I'm missing?
You can simply add this entry in your host file locally, and it will work.
On windows machine - C:\Windows\System32\drivers\etc\hosts
On *nix machine - /etc/hosts
It sounds like you didn't register the domain in either DNS or hosts file.
1.So if you are in an AD environment, please add a CNAME blog-test.localtest.me in your local DNS Forward lookup zone.
2.If you are going to access the website from public domain, then please purchase the domian from domain provider and point it to Server's public IP.
3.If you just want to access the website locally, please add the domain to hosts file.
The hosts record would looks like:
127.0.0.1 blog-test.localtest.me
I created a small hello world node app, then i hosted the app on digital ocean droplet, after that i can access my application on http://my_public_ip:3000
Felt happy π
Then i bought a domain name called helloworld.tk free domain from freenom.com
After that i install nginx as a webserver in my droplet then i added a reverse proxy code in /etc/nginx/sites-enable/default
My code looks like:
server {
listen 80;
server_name helloworld.tk
location / {
proxy_pass http://localhost:3000;
}
}
After that i went to domain management panel in my freenom.com and set url forwarding to http://my_public_ip
So if i enter my domain name helloworld.tk in browser my node app successfully works π€© but wait what π€ my ip address is showing on left side below corner on chrome and if i refresh the page multiple times i get
402 Too many request error page on nginx
So i deleted my url forwarding and in my domain management panel instead of url forwarding i set my nameservers like this ns1.digitalocean.com bla.bla.bla...
Then i added my domain in my digitalocean panel. Now yes everything is working perfect.
If i hit my url no ip address is showing, also no too many request errors π
My node app successfully getting executed!
Wait i am a beginner for hosting node app, so i need help whether it is correct good setup for nodeapp on production?
What is the difference between url forwarding and nameservers? Whether my nginx reverse proxy code is correct? is my reverse proxy working correctly?
NOTE: I used pm2 for running node app on background.
First, remove the forwarding and you need to change the nameservers of the domain in your domain DNS management if your domain is somewhere other than DigitalOcean
Add below nameservers:
ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
Now check if they are propagating by using whatsmydns.net (Enter your IP and change click on A and select NS and click Search)
Once they are propagating, add the domain to your DigitalOcean account.
Go to your DigitalOcean Dashboard and click on Networking.
Add a domain and click Save.
Then Edit the domain and add the Droplet to the Domain and save.
Now click on the domain name and an A record which points to your droplet.
Hope this will resolve your issue.
Go back to your DNS domain registrar ( freenom.com ) and remove mention of digitalocean nameservers and put back its own default frenom.com nameservers ... also on freenom.com assure you have defined a Type A record to point to your machine's external IP address
Your nginx config looks OK
this should work ... now had you defined digitalocean nameservers in your freecon.com registrar you would have then needed to go to https://cloud.digitalocean.com/networking/ and set up your Type A record there ... its critical to know the location of your nameservers determines where your Type A record must live
What you have to do is create a droplet in DigitalOcean and then add your domain name to the droplet in the Networking tab. You have to add both the non-www and www versions so the domain will be pointed correctly. You have to set the A records for those two to the IP of the droplet that DigitalOcean assigned to it.
Then from your GoDaddy/your domain manager, you have to go to ManageDNS and change the default GoDaddy name servers with those of DigitalOcean. Save it and you are done.
Wait for up to 24 hours and test the domain with check-host.net If all done correctly the domain should point to the servers of DigitalOcean in the city you have selected.
I created a NodeJs web on non-classic virtual machine in Azure cloud. Then I started the app on port 80 as follows:
sudo NODE_ENV=production PORT=80 node server/app.js
The app started successfully. I also enabled port 80 using NSG.
I can access the app using IP address.
Now I purchased a domain name in names.co.uk and linked the IP address to record A(on registrar site). The same way as I was doing for the AWS site which is currently working.
But I could not access the app using custom domain name but app can be accessed directly using IP address.
Any help in this regard will be much appreciated.
you can try to follow this guide on official site Create a Fully Qualified Domain Name in the Azure portal, configure with the CName on your DNS service leveraging the Domain. It works fine on my side.
Besides, if you don't see the "public ip address" as the capture shows on the guide, you can find the ip address in this steps:
As if you don't have a static ip address, the public ip may change when your VM start each time.
The way I did is absolutely correct. The only problem was that it took some time to get the changes reflected.
I am unsure Whether both DNS server and Host file are the same or different.
I Hosted an application in IIS and created A host name as website1.domain.com and tried to browse it and it didn't work.
When searching on net i found that we need to make entry in DNS server or Host file.
As in most of the sites that I saw mentioned DNS server or host file. I am unsure Whether the both are same or they both are different.
A hosts file is used by Operating Systems to manually specify the IP addresses for specific domains/subdomains - think of it as an override.
DNS however is a server - think of it as a registry - that keeps track of records pertaining to domains, such as A records, MX records etc.
For the purposes of a local test site, an entry in your hosts file would be sufficient, however for a live site, a DNS entry relating to the domain you wish to have your site hosted on would be required.
Choosing which to use comes down to a few things. Does the server upon which your hosting the site use its own DNS server, i.e. a DNS server on the same network, which the connections to the server will be using as well? Does the domain name the site uses have its nameserver set to one that is externally available (i.e. 123-reg.co.uk). If either of these cases are true, you could probably use a DNS server.
If not, is the server hosting the site running on the same machine as the client that will be viewing the site? If so, you can probably use a hosts file, pointing your domains to the localhost IP of 127.0.0.1, ensuring the domains match the bindings in IIS.
Dns server is a server that will help to resolve dns names. ie when you type google.com in your browser , the name will be passed to the dns server provided by your isp. then it will be resolved to ip address by the dns server and your request will be routed to the google ip address by isp network. host file is different one. if you add www.mydomian.com entry in your host file and map it to an ip address 192.168.0.1 then your computer will check ion your host file when you type www.mydomain.com, whether there is any entry for mydomain.com in your host file, and if exists it will be routed to that ip address. in case if there is dns server and you set that server ip in your hnetwork configuration in your pc, then all the domain name request will be sent to that dns server(if there is no host entry exists)