Ad Widget

Collapse

From Alias to Virtualhost

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • M@x
    Junior Member
    • Oct 2020
    • 4

    #1

    From Alias to Virtualhost

    Hi all !
    Apache2 and mysql are running my great zabbix.
    I can access it by typing: mywebsite.tld/zabbix and all works good.

    I'd like to access it by typing: zabbix.mywebsite.tld
    I've set up my DNS correctly.
    I created an apache2 virtualhost, same type as the other ones.
    Surprizingly, not working.
    I saw zabbix is accessed via /etc/zabbix/apache.conf which contains an alias /zabbix, not a virtualhost.
    I tried many things within, with and without this file; not working

    I also tried to ln -s /usr/share/zabbix/ to /var/www/html/zabbix, and set up my apache2 virtualhost to point to it insted of /usr/share/zabbix, and have set up www-data permissions on it; not working

    Is there any solution ?

    Thx !

  • gorekBoy
    Junior Member
    • Jan 2020
    • 10

    #2
    Hi!

    I assume virtualhost configuration is correct.
    Try set DocumentRoot parameter for your virtualhost to location of Zabbix frontend.
    For example:
    Code:
    DocumentRoot /usr/share/zabbix

    Comment

    • M@x
      Junior Member
      • Oct 2020
      • 4

      #3
      Thx man, allready done, did not work.
      Here is my /etc/zabbix/apache.conf:

      (as u c, i tried adding Alias line with domain, without effect.)
      (i also tried adding

      Code:
      <VirtualHost *:80>
      ServerName zabbix.mydomain.mx
      ServerAlias [URL="http://www.zabbix.mydomain.mx"]www.zabbix.mydomain.mx[/URL]
      DocumentRoot "/usr/share/zabbix/"
      CustomLog /var/log/apache2/access.zabbix.log combined
      </VirtualHost>
      instead of the rest, and added with it, without any result.


      Code:
      <IfModule mod_alias.c>
      Alias zabbix.mydomain.mx /usr/share/zabbix
      Alias /zabbix /usr/share/zabbix
      </IfModule>
      
      <Directory "/usr/share/zabbix">
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
      
      <IfModule mod_php5.c>
      php_value max_execution_time 300
      php_value memory_limit 128M
      php_value post_max_size 16M
      php_value upload_max_filesize 2M
      php_value max_input_time 300
      php_value max_input_vars 10000
      php_value always_populate_raw_post_data -1
      php_value date.timezone Europe/Paris
      </IfModule>
      <IfModule mod_php7.c>
      php_value max_execution_time 300
      php_value memory_limit 128M
      php_value post_max_size 16M
      php_value upload_max_filesize 2M
      php_value max_input_time 300
      php_value max_input_vars 10000
      php_value always_populate_raw_post_data -1
      php_value date.timezone Europe/Paris
      </IfModule>
      </Directory>
      
      <Directory "/usr/share/zabbix/conf">
      Order deny,allow
      Deny from all
      <files *.php>
      Order deny,allow
      Deny from all
      </files>
      </Directory>
      
      <Directory "/usr/share/zabbix/app">
      Order deny,allow
      Deny from all
      <files *.php>
      Order deny,allow
      Deny from all
      </files>
      </Directory>
      
      <Directory "/usr/share/zabbix/include">
      Order deny,allow
      Deny from all
      <files *.php>
      Order deny,allow
      Deny from all
      </files>
      </Directory>
      
      <Directory "/usr/share/zabbix/local">
      Order deny,allow
      Deny from all
      <files *.php>
      Order deny,allow
      Deny from all
      </files>
      </Directory>
      I also have that in /etc/apache2/sites-available/zabbix :

      Code:
      <VirtualHost *:80>
      ServerAdmin [email protected]
      DocumentRoot /var/www/html/zabbix/
      ServerName zabbix.mydomain.mx
      
      <Directory /var/www/html/zabbix/>
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
      </Directory>
      </VirtualHost>
      without any effect; of course, I did
      Code:
       sudo a2ensite zabbix.conf, same for zabbixssl.conf for :443 connections.
      Crazy, nothing seems to have any effect, <IfModule mod_alias.c> is the King of the Castle.
      Last edited by M@x; 07-10-2020, 15:54.

      Comment

      • gorekBoy
        Junior Member
        • Jan 2020
        • 10

        #4
        I' m not sure you need "Alias zabbix.mydomain.mx /usr/share/zabbix" line in /etc/zabbix/apache.conf.
        Show us your apache virtualhost configuration file.

        Comment

        • M@x
          Junior Member
          • Oct 2020
          • 4

          #5
          Quite not sure me too.

          You saw file in /usr/share/zabbix AND /var/ww/html/zabbix through theses conf files, because I made a
          ln -s beetween them 2 folders, so it's the same.
          Of course I first tried with the original path., then I thought "it might be the path", and seems not.

          zabbix.conf:

          Code:
          <VirtualHost *:80>
          ServerAdmin [email protected]
          DocumentRoot /var/www/html/zabbix/
          ServerName zabbix.mydomain.mx
          
          <Directory /var/www/html/zabbix/>
          Options Indexes FollowSymLinks
          AllowOverride All
          Require all granted
          </Directory>
          </VirtualHost>
          zabbixssl.conf

          Code:
          <IfModule mod_ssl.c>
          <VirtualHost *:443>
          ServerName zabbix.mydomain.mx
          ServerAlias www.zabbix.mydomain.mx
          ServerAdmin [email protected]
          DocumentRoot /var/www/html/zabbix/
          
          # 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
          
          # SSL Engine Switch:
          # Enable/Disable SSL for this virtual host.
          SSLEngine on
          Last edited by M@x; 07-10-2020, 22:45.

          Comment

          • gorekBoy
            Junior Member
            • Jan 2020
            • 10

            #6
            I replicated your config (made ln -s between folders and create virtualhost with content of your zabbix.conf) in my test environment and it works perfect.

            I suspect it maybe something wrong with your apache configuration. Try run:
            Code:
            apache2ctl -t
            apache2ctl -t -D DUMP_VHOSTS | grep zabbix
            Did second command return any result?

            BTW: You can remove "Alias zabbix.mydomain.mx /usr/share/zabbix" from /etc/apache2/conf-available/zabbix.conf. This line does nothing in your case.
            Last edited by gorekBoy; 14-10-2020, 22:22.

            Comment

            • M@x
              Junior Member
              • Oct 2020
              • 4

              #7
              Oh yeah thx !!!

              apache2ctl -t
              Code:
              Syntax OK
              apache2ctl -t -D DUMP_VHOSTS | grep zabbix

              Code:
              port 80 namevhost zabbix.mydomain.mx (/etc/apache2/sites-enabled/zabbix.conf:1)
              port 443 namevhost zabbix.mydomain.mx (/etc/apache2/sites-enabled/zabbixssl.conf:2)
              alias www.zabbix.mydomain.mx

              Comment

              Working...