Showing posts with label ISPConfig. Show all posts
Showing posts with label ISPConfig. Show all posts

Feb 3, 2014

Disable multi location access log in ISPConfig setup

This applies to ISPConfig 3.0.5.3 on Debian Wheezy 7.3.

By default, ISPConfig will save access log for each site at /var/log/ispconfig/httpd/<sitename>/access.log, and Apache also saves log for each vhost at /var/log/apache2/other_vhosts_access.log. If we have many sites hosted on the same server (of course that’s why we use ISPConfig), we do not want the same access log in 2 different locations which consumes server resources.

We can disable vhost access log of Apache by editing the config file
nano /etc/apache2/conf.d/other-vhosts-access-logthen comment out the line
#CustomLog ${APACHE_LOG_DIR}/other_vhosts_access.log vhost_combined Restart apache service apache2 restart

Jan 24, 2014

Enable HAProxy logging on CentOS

By default, HAProxy will not log to files unless we make some modifications
1. Create rsyslog configuration file
nano /etc/rsyslog/haproxy.conf
Add these lines to the file
# Enable UDP port 514 to listen to incoming log messages from haproxy
$ModLoad imudp
$UDPServerRun 514
$template Haproxy,"%msg%\n"
local0.=info -/var/log/haproxy/haproxy.log;Haproxy
local0.notice -/var/log/haproxy/admin.log;Haproxy
# don't log anywhere else
local0.* ~
Restart rsyslog service
/etc/init.d/rsyslog restart
Ref: http://blog.hintcafe.com/post/33689067443/haproxy-logging-with-rsyslog-on-linux
2. Modify the log rotate config to match the new folder:
nano /etc/logrotate.d/haproxy
Change
/var/log/haproxy.log {
    daily
    rotate 10
    missingok
[...]
to
/var/log/haproxy/*.log {
    daily
    rotate 10
    missingok
[...]
Now we can check if HAProxy logging is working.
tail -f /var/log/haproxy/haproxy.log

Jan 16, 2014

Log client's IP address in apache log when using HAProxy and ISPConfig

If we use HAProxy and ISPConfig to publish websites, by default, Apache log will log only the IP of the HAproxy server. To log client's IP in Apache log, we have to:

1. Config HAProxy
Add
option forwardfor to backend option in HAProxy config file, then reload haproxy
service haproxy reload
2. Change the LogFormat for ISPConfig site
Edit ispconfig config file nano /etc/httpd/conf/sites-available/ispconfig.conf Replace LogFormat "%v %h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" combined_ispconfig with LogFormat "%v %{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" combined_ispconfig
3. Change the LogFormat for httpd
Edit httpd.conf file nano /etc/httpd/conf/httpd.conf Replace LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined with LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined Save the file and restart apache server service httpd restart
Check the log again. Not as other guides, I still keep the %h because we sometimes need to test the webserver directly. Also, we want to log if there is any other IP accessing our webserver besides the HAProxy.