Cant access my website through its IP address - apache

I have hosting with godaddy with a private IP address. I am able to access my websites and others via the domain name, but not via IP Address.
I am now trying to access the HTTP via port 80 but it gives an error that the website is not setup.
Are there any workarounds on turning allowing accessing the website and other folders through the IP address over http?

This sounds to me like you were on a managed webpack that grants you access to the to-be-served content but not to the webserver or its config itself.
What you are experiencing there is an effect of a technique called virtual-hosts in which multiple sites are tied to one IP address. For this to work in the realm of HTTP, the Host header got introduced in HTTP/1.1. It allows clients to send a domain name for which they want to receive content.
If you request a raw IP, though, the Host header won't look like Host: example.com but rather like Host: 123.45.67.89. The server will not be able to associate a domainname with this as it is unlikely to be found elsewhere in the request. Therefore, it will be forced to serve content out of its default document directory which usually contains further documentations regarding the further configuration of the webserver in question. Linux distributions like to add additional informations specific to them. Check if you see any mentioning of e.g. Debian, RedHat, or Centos.
I am not sure if this is fixable. Usually webservers like Apache support IP-based virtual hosts. If a masshoster like godaddy is really going to address this is uncertain. Try to contact their support and see.

1]If you are using host headers, make sure you have a DNS entry pointing your URL to your IP
2]Telnet port 80 from a machine outside your network.If it fails then check with your ISP that port 80 should not block in firewall.

Related

how do my web server know the domain is mine?

I bought a domain and registered it on a dns server. But I wonder how my web server know whether the coming request is from my domain. E.g. someone registered his domain on my server too. Obviously apache should reject other domain's request. I just wanna know more details about how a web server (like apache) detect this. Does it simply set in the config file (maybe ServerName?) and do some string comparison?
Short answer: By default, if another person points their domain to your website, by default the webpages that are sent to their computer are the same webpages you use for www.yourdomain.com. You can also program your webserver to deny/redirect requests from other domains.
Long answer (I recommand you read):
A common newbie misconception is that domains are "TIED" to a web server. However, that is not true. They are completely different and somewhat unrelated. A domain is just shorthand for an IP address that correlates to your web server. An IP address is really what is TIED with your web server.
For example:
www.example.com could 'resolve'/correlate to 1.1.1.1
and
www.randomdomain.com could also resolve to 1.1.1.1
If 1.1.1.1 is the ip address your web server is correlated to, THEN these requests will both get sent to your web server.
Now, if you think about it, with this logic, you should be able to access your web server by just typing in 1.1.1.1 That is true!
Real world example:
www.google.com goes to Google
172.217.6.78 also goes to Google because 172.217.6.78 is one of the web servers google.com will correlate/resolve to. Go ahead and type 172.217.6.78 into your web browser. It will take you to google.com.
DNS servers point your domain to the IP address of your web server.
On your webserver:
Your server will run a software that will respond to requests it gets from the outside internet. This software will usually know how to respond to this requests using the correct syntax and also be able to handle multiple requests at the same time. When this software gets a request, it will load a file (that you specify) and send it to the user/client.
Common examples of this software include Apache (most famous/popular - runs like 40% of all websites you browse including facebook.com) and nginx (becoming more popular).
The default config of an Apache/nginx/etc web server is to serve that user (at port 80) the documents that are in the 'www' folder. However, (for Apache) if you would like to serve multiple domains on one web server (www.example.com & login.example.com), you would usually create virtual hosts. Creating virtual hosts can be done by editing your Apache configuration file. (If you're hosting on GoDaddy/namecheap or something similar, you won't have access to this.)
An example of a basic virtual host could be:
<VirtualHost *:80> #80 for port 80 - the standard port for unencrypted web traffic
ServerName www.yourdomain.com
DocumentRoot /where/your/web/files/are/located
<VirtualHost>
You could then create another virtual host to reject/forward another domain's traffic
<VirtualHost *:80>
ServerName www.randomotherdomain.com
#here, you could either serve new content to this domain using "DocumentRoot" or you can forward all traffic to your website
Redirect / http://www.yourdomain.com
<VirtualHost>
However, by default, if another person points their domain to your website, by default the webpages that are sent to their computer are the same webpages you use for www.yourdomain.com

website can be accessed using ip but not with the url(domain name) in wamp

from default httpd.conf to updating the host file and httpd.conf i tried but the website fails to open with domain name give
in host file
<my current public ip address> <domain name>
in httpd.conf
Listen [my public ip]:port
then restart of wamp server and finally restart of PC and of-course change of ip is done in above all.
But of no use
Please help
Thanks for time and response
Aaron,
I think you are misunderstanding the function of the HOSTS file.
The hosts file acts a little like a local DNS Server. Any changes you make to it will only effect the single PC that you made the change on.
What the HOST file actually does
When windows starts it starts a service called DNS Client also known as dnscache. That service reads the HOSTS file and seeds the dnscache with any domain names you put in it and the ip that should be connected to for each domain name.
Any program (the browser in this case) that wants to connect to a domain, checks this cache first, to reduce accesses to an actual DNS Server out on the web and therefore speed up the conversion of domain name to Ip Address.
So if you want external users, i.e. anybody on the internet to be able to access your site you have to either purchase a real domain name and get it pointed to your WAN ip address, or use a Dynamic DNS service like DYNDNS or NO-IP, to mention only a few, and get that dynamic dns service to point to your WAN IP.
You will also have to change your Apache config so it will serve that domain name, my suggestion would be to create a Virtual Host to do this.
This post may help with the process of creating a Virtual Host

Apache not able to access document root when outside the network

I have a wordpress site on my debian server. I have done the port forwarding successfully (verified this) to access outside the network. However I get the below error when i try to access outside the network. Am i missing something? Sites-available is set to documentroot at /var/www, which is where my wordpress folder is.
The requested URL /XXXXXX was not found on this server.
Apache/2.2.22 (Debian) Server at 10.1.1.4 Port 80
I really hope someone can help me on this as i have spent almost a week over this.
Thanks!
I do this kind of stuff on daily basis. Lets go through the basics.
Firstly, confirm that you can access your server within your private network http://yourserverLANip:80
If possible, do not use server itself to test it (eg localhost:80), use other device as laptop or any other device within the same LAN.
With that test you can confirm that:
apache listens on port 80
apache accepts requests from other clients within your private network
wordpress is set up correctly
If wordpress site pops up we can assume that apache and private network configuration is correct and you'd need to move your debugging to WAN/public network configuration.
It would be wise to recheck apache security settings at this point.
From here, things get a little more complicated.
I believe you mean public WWW when you say "outside-the-network". You want to make your site public to every internet user on the planet.
I assume that you have a registered domain name (eg yourwebsitename.com) and a static public IP address at the location where the server is located (if you host it at home, static IP is fixed to your modem).
These two are "must", if you want to host anything that public can consume.
If you host your apache for yourself, you dont need your domain name, but you'd need to access your server through your public IP yourpublicIP:80 and it's not easy to use for other people.
Now lets go on with WAN debugging.
Validate that:
your domain DNS WWW settings are pointing to your public IP address
at your server location. you can do it through the control panel of
your domain registrant company.
you have a static public IP address where your server is hosted
your modem accepts incoming ports (80). this is done through modem
firewall settings.
that the port 80 is redirected to your server private IP address (LAN
ip).
The flow for redirecting clients to your server is something like that:
Client->WWW->internet service provider->yourpublicIP->modem->yourserver at LAN
Good hunting!

Apache - multiple sites on one IP, domain and port with SSL

Is it possible to run multiple apache sites on the same IP, domain and port (meaning the <VirtualHost> tags are exactly identical and no ServerName is given) while using SSL (not sure whether SSL makes a difference here)?
I would like to separate my web services into files in etc/apache2/sites-available to be able to activate or deactivate them on demand. Basically Apache should just take all files and string them together internally, but leave me the possibility to a2dissite certain parts.
Further clarification:
By "sites", I mean files in the etc/apache2/sites-available directory. "Web services" in this context are certain application like phpMyAdmin or an Etherpad which run on the Apache and whose configuration (e.g. Alias or ProxyPass) I want to write into its own configuration file ("site"),
The short answer is no.
SSL operates at a level between TCP and HTTP. But the virtual host name is sent via HTTP. So how does SSL know which certificate to use for a virtual host?
There is a way to do it - basically start up the HTTP over TCP then switch to SSL after the virtual host name (in the Host header) is sent. However this is complex, error prone and generally considered a bad idea.
Best practice is to have one IP per SSL. One machine can have multitple IP addresses, even a single network port can have mulitple IP addresses.

Apache unable to access local DNS ip address

I just set up a server in my house using private IP.
I can access my server using my domain from outside network/ outside from my house.
But I cannot access it from local network using my domain or my private IP address.
What can be the problem for this? is it the Apache settings?
(I can access it if I edit the /etc/hosts file)
Did you use the internal or external IP in your hosts file to get it working? If it was external IP it's probably the DNS issue. If it was the internal IP, the issue could be in the routers NAT.
Some routers/setups will only apply their NAT rules on packets traversing the external internet facing interface.
____________
| |
Server ---IntIf-|IntIP--ExtIP|-ExtIf--- Internet
|____________|
This is a bit simplified but basically when you access the external IP from the internal network the packet, following the dotted line, reaches the routers external IP before a NAT rule can be applied on ExtIf and then the router can't find anything listening so rejects/drops the connection.
To confirm if it is the DNS problem. Run an nslookup $domain from both your local and external boxes and see if they return the same IP address. If the IP's are the same and it's still not working you will need to take a closer look at the router, hopefully that's possible. If not you may need an internal DNS server that can respond with the internal IP addresses for any domains it knows about then forward any other requests externally.
The NAT issue is called NAT Loopback, Hairpinning or Reflection. See here for a linux solution.
If you can access it when you put in an entry in /etc/hosts, then likely it is DNS related. I am assuming you are putting in the public (external IP) and not an internal IP for testing.
If you have recently updated your DNS, then likely your local router (or ISP's DNS server) will still have the old IP cached or the fact that there is no DNS record setup cached. You could reboot your router to try and clear the cached entry, but it could well be cached at the ISP and you can only wait until it updates there (usually somewhere under 24 hours, often just a few hours). However, you could configure your computer to use a different DNS server for a while - eg. 8.8.8.8 or 4.4.4.4 which are both run by Google.