0

My travel in the world of Linux continues. I've successfully installed and configured CentOS, LAMP, and Zabbix on real machine. Now my problem is that to get access to zabbix, I should type, for example, 192.168.1.1/zabbix, to load the Web interface of the server; but, I want to type only 192.168.1.1. That means that the Web interface of zabbix should be available via port:80 by default.

I've found that it should be changed in Apache's httpd.conf under Aliases. I've added an uncommented string in that configuration file using full paths to zabbix, zabbix.conf.php/maintenance.inc.php).

Alias /var/www/html/ /etc/zabbix/web/

But there is no effect.

I suppose that it won't work, so I ask for help: what to do? What to search?

Thank you

  • 1
    Offhand, but /etc/ is really not the place you want to put an entire web directory. – Shadur Oct 27 '17 at 12:32
  • @alexandr-anufreiv: Any luck yet? – RubberStamp Oct 27 '17 at 17:17
0

There are two basic methods of dividing a domain's web space. You can divide it into subdomains via the "VirtualHost" directive, or you can place hierarchical locations within the root of the web space.

Or some combination of the two.

The Alias directive assigns a hierarchical location. So, in your example, the correct way to assign the web space root to a filesystem directory is:

Alias "/" "/etc/zabbix/web/"

For further reading: Apache mod_alias

Make sure that your web server's user has read access to the directory you are aliasing. Remember that directories are "executed" which means that all directories within the webspace need to have the execute bit set for the web server's user.

  • Ok, we've moved from place, after changing Alias to (as you recommended): Alias / /etc/zabbix/web/ trying to acces 192.168.1.1 shows me: Forbidden You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request. – Alexandr Anufriev Oct 27 '17 at 13:15
  • This is because the web server's user... probably "www-data" or something like that... does not have have read permissions in that filesystem directory. It's not a good idea to place web locations within /etc/ ... it can be done, but it's not good. Common locations are /var/www/html or /usr/share/somedirectory – RubberStamp Oct 27 '17 at 13:21
  • That was an answer, thank you. Added Alias "/" "usr/share/zabbix/" and it solved the problme. – Alexandr Anufriev Oct 28 '17 at 11:46
0

You don't need to redirect anything.

By design, when Apache receives a request that does not contain a server name, it defaults to the first VirtualHost entry as loaded into its configuration.

This page gives instructions on how to modify individual virtual hosts in CentOS; I can't tell how valid that is for your situation since I don't use CentOS myself, but what you basically want is to make sure that the first (or only) VirtualHost stanza loaded is one that has its DocumentRoot set to /etc/zabbix/web -- and may I once again strongly recommend that you move the web files for zabbix to someplace sane like /var/www/zabbix/ and work from there?

This should look, roughly, like this:

<VirtualHost *:80>
        ServerName my.zabbix.site

        DocumentRoot /etc/zabbix/web/

        TransferLog /var/log/apache2/zabbix-access.log
        ErrorLog /var/log/apache2/zabbix-error.log

</VirtualHost>

Although again I cannot overstate how bad an idea it is to put a web-accessible directory under /etc/. Don't do this if you don't have to and don't know exactly what you're doing.

  • 1). I dunt use any VM. I use real server with Centos + LAMP + ZAbbix on it. 2). When i type 192.168.1.1 in my web-browser it chows me initial Apache test index site "Apache 1 2 3". 3). I need to configure apache conf (httpd.conf i suppose) in the manner, whenever i will type 192.168.1.1 in my browser, outpout will be just like now it is by 192.168.1.1/zabbix – Alexandr Anufriev Oct 27 '17 at 12:54
  • You misunderstand. I'm not talking about a virtual machine in the style of VMware. This is how Apache works internally to allow you to host multiple websites on a single system. I'll add some documentation links so you can see what I mean. – Shadur Oct 27 '17 at 12:56
-1

Added Alias "/" "/usr/share/zabbix"

Seems that was a solution, i suppose, but not sure cause i was lost in all that changes in httpd.conf around Alias strings and DocumentRoot.

and now my server available via ip 192.168.1.1 (example) in browser without /zabbix/ after it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.