Redirect IP to domain help

I just noticed that if put https://1.1.1.1 and not http://1.1.1.1 it doesnt redirect to the domain

That’s the opposite of what I would expect. Weird.

Is there an /etc/apache2/sites-available?

If so, a2ensite 000-default.conf

If not, create it. It contains the following by default (but it would be better if you made it specific and gave it a name):

<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Oh, but even if you re-enable the 000-default site, it won’t fix the problem. Your named VirtualHost will still be more specific, because it has an IP.

So, the solution continues to be you need to make a VirtualHost specifically for your Cacti installation (it can point to /var/www/… or you can move Cacti to a Virtualmin domain in /home, whatever). The VirtualHost will need an IP in the VirtualHost identifier.

Or, I guess you could modify 000-default.conf to change <VirtualHost *:80> to <VirtualHost 1.2.3.4:80> so it is specific enough to where Apache will serve it. Otherwise, we’re back to my original answer which is that the best-first match will be served (and IP being defined makes your other virtual host “best”, even if it’s not first).

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.