Subdomain to html - html

First of all I want to say that I'm new to the workings of DNS and server behavior.
Now I recently purchased a domain name, which redirect to my VPS IP adress.
on my linux VPS I have 2 folders with html files:
/var/www/html/home (containing):
home.html
/var/www/html/admin (containing):
admin.html
Since on the dns you can only type in an IP adress i don't know how to redirect the following:
admin.domain.nl -> html/admin/admin.html
domain.nl -> html/home/home.html
I want to have this working before launching a Java EE application.

You don't do that type of routing using DNS.
DNS maps a hostname to an IP addresses, so your DNS configuration would look like this (using made-up IP addresses):
domain.nl A 123.45.67.89
admin.domain.nl CNAME domain.nl.
Then you configure your web server (Apache?) to serve different content based on the hostname included in the HTTP request. This is called "virtual hosts" in apache.
How to set this up is off-topic for StackOverflow

Related

Deploy Content on Private IP Address?

I was reading about port forwarding which got me excited to try it myself.
But I'm stuck on the first step, given an html file how can I deploy it on my laptop's private ip address with custom port?
For example, imagine my laptop's ip is 10.0.0.4
Then when typing: 10.0.0.4:9011 in the browser I want to see the contents of the file.
Port forwarding would only be necessary if you want to make your laptop/server accessible outer your home network.
It is not only about port forwarding, you also need to install and run a server service like apache if you want to open that html file in a browser.
Additionally your laptop's public IP is probably not static. Almost all internet providers give you a dynamic IP for personal use. Which means that you need to use a different IP everyday to access that file.
However if you want to use that file only in your home network, then you still need a service like apache to host your file but you dont need a port forwarding + you can make your local IP static.
Here is a useful blog to host a website on your pc

Hosting HTML page with mp4 video in IIS 8 not working with hostname

I have a simple html page with video element that plays a video file of mp4 extension. I hosted the page in IIS 8. The MIME Type is configured correctly by default. If I browse using the server name it works fine but when I use the hostname the video does not play. The domain is from Godaddy and it is pointing to our public IP and then we have a load balancer that directs the requests to the two nodes servers.
Any ideas what could be the problem?
If you are able to resolve and access the server by server name then you must be calling the server from the internal network and are likely resolving to the internal IP address.
When you are calling the domain name then this will likely be resolving the public IP address from the DNS server where the A record is being hosted - GoDaddy.
ping <server name>
ping <dns name>
In order to test, please update your hosts file with the DNS name resolving to the internal IP address.
%WinDir%\System32\Drivers\Etc
<internal IP address> fqdns.com
If you try to call an external IP address being provided by a DNS server (GoDaddy) it is probably located on your firewall. Your connection will likely be dropped by the firewall due to anti-spoofing rules.

Why different Google services has the same IP address?

I'm starting to study DNS system and the way it works. I'm using dig on ubuntu to solve some domain names and I'm trying with different Google services.
Even if services are totally different, it happened that I received the same IP address.
$ dig docs.google.com
;; ANSWER SECTION:
docs.google.com. 264 IN A 216.58.198.14
and
$ dig drive.google.com
;; ANSWER SECTION:
docs.google.com. 264 IN A 216.58.198.14
In other occasions, I received the same address trying to solve yet more services like mail.google.com or maps.google.com.
Can anybody help me and explain me the way it works? Does this have anything to do with time?
Thank you a lot.
First of all docs.google.com and drive.google.com are different domains.
And yes different domains can have the same ip address. This is called a Shared Web Hosting.
In name-based virtual hosting, also called shared IP hosting, the virtual hosts serve multiple hostnames on a single machine with a single IP address. This is possible because when a web browser requests a resource from a web server using HTTP/1.1 it includes the requested hostname as part of the request. The server uses this information to determine which web site to show the user. When you register/purchase your domain name on a particular "registrars name server", your DNS settings are kept on their server, and in most cases point your domain to the Name Server of your hosting provider. This Name Server is where the IP number (currently associated with your domain name) resides.

How to set a name for Apache server?

I created successfully a apache server but I dont want to connect to it by typing 192.168.0.102, I want a normal url like www.google.com. How can I do that? I went to httpd.conf and found the ServerName line but setting it to something like www.mysite.com doesnt seem to work. I also tried to use my external ip(https://www.whatismyip.com) as server name but it doesnt connect. It only works if I try to connect to 192.168.0.102 or localhost. How do i solve this? Thanks
There are three basic things you need to know.
Virtual name hosting
HTTP allows multiple websites to be hosted on the same IP address and port. The client uses the Host request header to tell the server which site it wants to get data for.
ServerName is used as part of this.
… but the client needs to know how to send a request to the server first.
DNS
When a client makes a request to a server, it uses the IP address of the server in order to allow it to be passed over the network (or networks) to it. It is the address.
IP addresses are sequence so of numbers, which aren't very friendly for humans to work with.
DNS translates friendly names (like www.example.com) into IP addresses.
The client has to look up the name to find the IP address. It normally does this through the main DNS system, and in order to get your name linked to your IP address you will need to find a domain name registrar and pay them.
It is also possible to set up DNS at a local level on a private network, and on a computer-by-computer level using a hosts file.
Routing
The IP address of the server has to be routable from the computer the client is running on.
192.168.0.102 is a private address, accessibly only on the same LAN. To make it accessible to clients on the Internet you need to either:
Set up your router to use port forwarding and then use the Internet facing IP address of the router (which https://www.whatismyip.com tells you) or
Give your computer a public IP address and configure your router to route traffic to it (this generally isn't possible on consumer grade routers).
In short, you can't. 192.168.0.102 is not accessible from the Internet it is internal IP.
But you have some alternatives, like if you like to access your computer from a hostname you can use dynamic DNS servers.
Or you want to test your code on a spectacular domain, you can add 192.168.0.102 with a domain to your hosts file, then only you can use this domain with your local computer.
But, If you really want to serve some content to the Internet from your local computer you have to find a DNS server service (like cloudflare) to point your domain to your public Internet ip not to 192.168.0.102.
You configure the virtual host and set the server name to the domain name you want. After that, Apache will check the requests and will use that virtual host if a request was made for that domain name. In order for that to work, that domain should point to your IP address where the server is running.
If you want to test if the configuration works, edit your /etc/hosts file and add that domain name to 127.0.0.1. After that you will be able to access to that virtual host if you try to access to that domain name from your browser.
More info here : https://httpd.apache.org/docs/current/vhosts/name-based.html

External IP address appears instead of Domain Name

I am running a website in Google Compute Engine and configured a DNS zone and an A record to point to the IP address where my web-server runs. In my domain registrar (GoDaddy), I changed name-servers to point to Google name servers.
I can browse to the website without issues, but it show the IP address of the server instead of domain name. How can I change that to show domain name such as www.example.com instead?
I have a website hosted in GCE running under a Linux machine Apache Server. I created an A record in my DNS pointing to the external IP address of the server. When I access the link the subdomain name is not replaced by the IP. I do not believe your issue is particularly related to Compute Engine.
Particularly if you are using WordPress you will need to change some configuration files as stated in
http://codex.wordpress.org/Changing_The_Site_URL
https://wordpress.org/support/topic/browser-displaying-ip-instead-of-domain-name
The below solution worked for me,
GCP set IP Address as site URL when you deploy WordPress on google cloud.
Please change it to your domain name,
WordPress Admin Panel >> Settings >> Site URL (& WordPress URL as
well) >> add your domain name into textbox
Attached is the image for your reference.