I'm having trouble understanding how to reconfigure the initial zabbix.conf file to not hijack port 80 out of the box.
Here is the default zabbix.conf provided by the application:
#
# Zabbix monitoring system php web frontend
#
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<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 always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
What I want to be able to do is configure my zabbix similar to how I've done other apps on my server something like this. There are actually already 2 apps on this server. jira which is a Reverse Proxy on port 8080 and confluence which is a Reverse Proxy on port 8090. I want to have zabbix on a Reverse Proxy on another port, say 8070.:
<VirtualHost *:80>
ServerName zabbix.domain.com
ServerAlias zabbix
Redirect / https://zabbix.domain.com
</VirtualHost>
<VirtualHost *:443>
ServerName zabbix.domain.com
ServerAlias zabbix
Include ssl/default/ssl.cfg
ProxyPass / http://localhost:8070/
ProxyPassReverse / http://localhost:8070/
</VirtualHost>
The problem is this doesn't work because Zabbix runs on the assumption that nothing else is using port 80.
Doing something like this just gives a page not displayed
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<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 always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
<VirtualHost *:80>
ServerName zabbix.domain.com
ServerAlias zabbix
Redirect / https://zabbix.domain.com
</VirtualHost>
<VirtualHost *:443>
ServerName zabbix.domain.com
ServerAlias zabbix
Include ssl/default/ssl.cfg
ProxyPass / http://localhost:80/
ProxyPassReverse / http://localhost:80/
</VirtualHost>
I was so close! Doing this -
<VirtualHost *:80>
ServerName zabbix.domain.com
ServerAlias zabbix
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<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 always_populate_raw_post_data -1
php_value date.timezone America/Toronto
</IfModule>
</Directory>
<Directory "/usr/share/zabbix/conf">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/app">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/include">
Require all denied
</Directory>
<Directory "/usr/share/zabbix/local">
Require all denied
</Directory>
</VirtualHost>
Allowed me to hit the URL of http://zabbix.domain.com/zabbix and get the site.
Actually you should change this in Apache conf. You can search for it like so:
grep -rE "\b80\b" /etc/apache2
You will get a list of places to change. That would most probably be something like Listen 80 and <VirtualHost *:80>.
Note that original zabbix configuration doesn't have any configuration for ports.
So after changing what you need you should restart apache and make sure it is running:
service apache2 restart
service apache2 status
URLs
Also note that you don't need ServerName in VirtualHost. Zabbix will only "hijack" the "zabbix" folder and only on specific port on which apache is listening. So if you changed 80 to 8081 you should see zabbix running on:
http://localhost:8081/zabbix/
And if your machine is accessible from external domain like zabbix.domain.com then this will work fine:
http://zabbix.domain.com:8081/zabbix/
Related
Server is running on RHEL 7.9, httpd 2.4.6 and I have the following structure in my /var/www/html directory:
/site
index.php
I can reach the root index.php by visiting the IP address. However, when I try to access content inside /site directory, it automatically switches to https, hence the content does not load.
Some snippets from /etc/httpd/conf/httpd.conf:
DocumentRoot "/var/www/html"
<Directory />
AllowOverride None
Require all denied
Options -Indexes +FollowSymLinks
</Directory>
<Directory "/var/www/html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
IncludeOptional conf.d/*.conf
I have a virtual host setup for /etc/httpd/conf.d/site.conf
<VirtualHost <server ip>:80>
ServerAdmin webmaster#sitename.com
DocumentRoot /var/www/html/site/
ServerName www.sitename.com
ServerAlias sitename
<Directory /var/www/html/site>
Require all granted
</Directory>
</VirtualHost>
I am setting up a webserver in CentOS 7 with multiple virtual hosts which includes a drupal website. I want to log the PHP errors of my Drupal website, say 'mysite' to a custom file say, /var/log/httpd/mysite_error.log. I have set this up in the httpd conf file of the virtual host (and this has worked for non-Drupal sites) but the errors are still logged to /var/log/php_error.log.
httpd conf file of the virtual host mysite (/etc/httpd/sites-available/mysite):
<VirtualHost *:80>
ServerName mysite
DocumentRoot /var/www/html/mysite/
<Directory "/var/www/html/mysite">
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/mysite_error.log
CustomLog /var/log/httpd/error_log combined
</VirtualHost>
You're just defining the Apache error log. For php you need php_value error_log /path/to.log.
See most topvoted answer at error_log per Virtual Host?
For Php Errors you have to configure them too, and they're are not ErrorLog or CustomLog as you declared here, these are servers log. Php errors variables start with php_value or php_flag.
<VirtualHost *:80>
ServerName mysite
DocumentRoot /var/www/html/mysite/
<Directory "/var/www/html/mysite">
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/mysite_error.log
CustomLog /var/log/httpd/error_log combined
php_flag log_errors on
php_flag display_errors on
php_value error_reporting 2147483647
php_value error_log /var/www/domains/example.com/php.error.log
</VirtualHost>
Using Ubuntu 16.04, apache2.
I have the following virtual host in apache, but my URL http://example.com/phpmyadmin gives a 404 error. Any ideas?
From looking at other stackoverflow posts, this should work, but it isn't working. I'm fairly new to the Linux/Apache world (if this was on IIS I'd be fine!) so if you can give any pointers that'd also be appreciated.
<VirtualHost *:80>
ServerName example.org
Alias /phpmyadmin/ /user/share/phpmyadmin/
DocumentRoot "/var/www/html"
<Directory /usr/share/phpmyadmin>
Require all granted
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen Off
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
</IfModule>
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>
<Directory "/var/www/html">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
Thanks in advance.
I am a newbie in wampserver.
I installed it and I can acesss web pages with localhost port 8000 without problems. Yes, I changed default port to 8000 and all works well with localhost.
Now, I created a simple project web page and I need external access. Here is my settings:
But I get the next error when I try to acesss remotely:
Forbidden
You don't have permission to access / on this server.
Apache/2.4.23 (Win64) PHP/5.6.25 Server at agenda.myvnc.com Port 8000
//agenda.myvnc.com is my elastic IP host server
My sample project:
Folders:
c:\wamp64\www
...........cloudappoint.myvnc.com(subfolder in www)
File in cloudappoint.myvnc.com folder: index.php
NOIP DNS:
- Host:cloudappoint.myvnc.com
- Target IP:XXX.XXX.XXX:8000(My host is located at amazon ec2 with elastic ip- XXXX.XXX.XXX)
- type:URL
WampServer VirtualHosts:
<VirtualHost *:8000>
ServerName cloudappoint.myvnc.com
DocumentRoot c:/wamp64/www/cloudappoint.myvnc.com
ErrorLog "logs/agenda-error.log"
CustomLog "logs/agenda-access.log" common
<Directory "c:/wamp64/www/cloudappoint.myvnc.com">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EDITED: Here is my complete Virtual hosts file:
<VirtualHost *:8000>
ServerName localhost
DocumentRoot c:/wamp64/www
<Directory "c:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8000>
ServerName cloudappoint
ServerAlias cloudappoint.myvnc.com
DocumentRoot c:/wamp64/www/webagenda
ErrorLog "logs/agenda-error.log"
CustomLog "logs/agenda-access.log" common
<Directory "c:/wamp64/www/webagenda/">
Options +Indexes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I am unable to acesss remotely cloudappoint.myvnc.com, but if I move
<Directory "c:/wamp64/www/webagenda/">
Options +Indexes +FollowSymLinks +MultiViews
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
out from VirtualHost, all works well. Then, I guess 3.06 has broken Directory into Virtual Hosts.
I'm trying to get a simple .htaccess rewrite rule to work, but I can't seem to work it out.
My .htaccess looks like:
RewriteEngine On
RewriteRule ^api$ phpinfo.php
ErrorDocument 404 /error.php
php_flag display_errors on
php_flag display_startup_errors on
php_flag file_uploads on
php_value error_reporting 2047
php_value max_input_time 60
php_value post_max_size 8M
php_value upload_max_filesize 2M
When I access /api, I get a 404 error saying that /api can't be found.
My apache conf file looks like:
<IfModule mod_ssl.c>
NameVirtualHost 10.104.17.3:443
<VirtualHost 10.104.17.3:443>
ServerName orddev.foo.com.au
DocumentRoot /var/www/orddev.foo.com.au___443/html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory "/var/www/orddev.foo.com.au___443/html">
Options FollowSymLinks MultiViews IncludesNOEXEC
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_php5.c>
php_admin_value upload_tmp_dir "/var/www/orders.foo.com.au___443/resources/_tmp/upload/"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
</IfModule>
ErrorLog logs/orddev.foo.com.au___443/ssl_error.log
CustomLog logs/orddev.foo.com.au___443/ssl_access.log combinedio
CustomLog logs/orddev.foo.com.au___443/ssl_request.log ssl
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:!SSLv2
SSLCertificateFile /etc/pki/tls/certs/orddev.foo.com.au.crt
SSLCertificateKeyFile /etc/pki/tls/private/orddev.foo.com.au.key
<Files ~ "\.(cgi|shtml|phtml|php|php3?)$">
SSLOptions +StdEnvVars
</Files>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
</IfModule>
Any idea what I'm doing wrong?
I know the .htaccess is being read as if I change the 404 document, I get an error about the 404 document not being setup properly.
I had a working .htaccess file that I switched over to another server. It was working fine before and stopped working after the switch. I solved the problem by configuring the httpd.conf file.
SSH onto your server and open the httpd.conf file for editing:
cd /etc/httpd/conf
sudo nano httpd.conf
find the "Directory" tag. Should look like this->
<Directory "/var/www/html">
Replace AllowOverride None with
AllowOverride All
Restart
sudo service httpd restart
It sounds like your apache isn't loading mod_rewrite.
Locate your httpd.conf and search for "rewrite_module".
If that line begins with a # (making it a comment), remove the # and restart apache.
In mine, the line is:
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
...but YMMV.