使用nginx代理httpd;
默认httpd中zabbix的配置文件是/etc/httpd/conf.d/zabbix.conf,这个配置文件定义了zabbix的web界面程序所在路径。为了让httpd监听8080端口,还需要修改httpd.conf
[root@DasonCheng ~]# vim /etc/httpd/conf/httpd.conf
#Listen 12.34.56.78:80
Listen 8080 //将监听端口修改为8080;
……
root@DasonCheng ~]# systemctl restart httpd
[root@DasonCheng ~]# netstat -lntp |grep httpd //监听端口已经变成8080了;
tcp6 0 0 :::8080 :::* LISTEN 13301/httpd
……
[root@DasonCheng ~]# vim /usr/local/nginx/conf/vhost/zabbix.conf
server
{
listen 80;
server_name www.zabbix.agent.com; //定义域名;
location /
{
proxy_pass http://192.168.60.11:8080/; //定义ip端口
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
……
[root@DasonCheng ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@DasonCheng ~]# /usr/local/nginx/sbin/nginx -s reload
[root@DasonCheng ~]# netstat -lntp |grep "nginx\|httpd"
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13455/nginx: master
tcp6 0 0 :::8080 :::* LISTEN 13301/httpd
测试:
OK!效果实现了;