-1

I hosted my several websites on Linode, they are all sharing a same IP address. I use webmin/virtualmin to manage my server and websites. Is it possible to visit one of the websites by IP address? Currently if I visit the IP, what shows in the browser is just an apache2 default page: http://45.79.146.98/. I think this also points to some folder on my server, but I don't know where it is.

P.S. If I can visit my websites by http://45.79.146.98/something, it is also acceptable. But I don't know where to start doing this.

3
  • 1
    I'd say that the first VHost in your apache config is the one showing when no FQDN is defined. Try placing the site you wish at the top of the others, it may work.
    – sysfiend
    Dec 20, 2016 at 13:12
  • Isn't that answer what OP is looking for ?
    – Tolsadus
    Dec 20, 2016 at 13:26
  • 1
    Agree, Apache docs: The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first <VirtualHost>. @Alex should make this an answer rather than a comment.
    – marctxk
    Dec 20, 2016 at 13:29

3 Answers 3

2

Making my comment an answer thanks to docu provided by @marctxk

The first VHost in your apache config is the one showing when no FQDN is defined. Try placing the site you wish at the top of the others and that's the one being shown when just accessing by IP address.

Apache docs:

The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first

5
  • so it is not possible to have all of them being able to be visited by IP?
    – shenkwen
    Dec 20, 2016 at 19:50
  • 2
    @shenkwen Why are you so set on visiting them via IP? If having a proper hostname is so much of a problem, then just add the requisite entries to your hosts file.
    – EEAA
    Dec 20, 2016 at 20:36
  • my websites have mirror image on a server in China. Everyday that server syncs the files from the linode server, and ppl from China are actually connected to the Chinese server. The person in charge of updating the website was in the U.S., now that she went back to China, she had trouble updating the website, because what she actually connects to is the Chinese server. So I think if she can visit the website by IP, then she can update the website as usual.
    – shenkwen
    Dec 20, 2016 at 20:50
  • 2
    So do what EEAA advises, and reconfigure her hosts file to have the linode server (if she can connect to it, given the Great Firewall). And in future, ask the question you actually want to know the answer to (see also the XY problem).
    – MadHatter
    Dec 20, 2016 at 22:28
  • Totally agree with @EEAA. It is not worth reinventing the wheel (backwards in this case)
    – sysfiend
    Dec 21, 2016 at 8:41
0

In your virtual hosts configuration file, it should be possible to define the Servername as your ip address.

Example:

<VirtualHost 45.79.146.98:80>
ServerAdmin [email protected]
ServerName 45.79.146.98
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

From the apache documentation

Syntax: ServerName [scheme://]domain-name|ip-address[:port]

-1

Opening that ip address in browser it tells that this file is located at /var/www/html/index.html

Edit. As OP owns server, then yes. You can modify that vhost and apache config too. I thinked that linode is doing virtual hosting. But it is doing virtual server hosting. So then op has full control of server. You must modify default config in /etc/apache2/sites-enabled directory.

In that configuration file change path from /var/www/html/ to your sites path.

1
  • Why not? How do you think that the OP would not have access to this?
    – EEAA
    Dec 20, 2016 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .