由於最近等保要求除了服務器的80和443端口打開外,其他端口建議都關閉,而裝了zabbix服務端的服務器之前是用http代理zabbix客戶端的,並且nginx代理的服務已經占用了80和443端口,所以之前http使用的是9000端口。
我這里一開始是想用nginx代理http服務來解決這個問題,但經過測試后發現,雖然能代理過去,但是把http的9000端口對外網訪問關閉后就會訪問不了;故此方法達不到要求。那么就只有把zabbix遷移到nginx,用nginx來做代理,這樣就可以把外網的9000端口關閉了;下面是操作記錄:
1、經檢測后發現沒有安裝php-fpm,所以第一步先把php-fpm安裝好:
[root@dxm-beta available]# rpm -qa |grep php php-cli-5.6.40-12.el6.remi.x86_64 php-ldap-5.6.40-12.el6.remi.x86_64 php-gd-5.6.40-12.el6.remi.x86_64 php-pecl-jsonc-1.3.10-2.el6.remi.5.6.x86_64 php-pdo-5.6.40-12.el6.remi.x86_64 php-pecl-zip-1.15.2-1.el6.remi.5.6.x86_64 php-5.6.40-12.el6.remi.x86_64 php-bcmath-5.6.40-12.el6.remi.x86_64 php-xml-5.6.40-12.el6.remi.x86_64 php-common-5.6.40-12.el6.remi.x86_64 php-mysqlnd-5.6.40-12.el6.remi.x86_64 php-mbstring-5.6.40-12.el6.remi.x86_64
#yum list installed | grep php --檢測php已安裝的包
#追加CentOS 6.5的epel及remi源。 # rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
#使用yum list命令查看可安裝的包(Packege) # yum list --enablerepo=remi --enablerepo=remi-php56 | grep php
#yum源配置好了,下一步就安裝PHP5.6 #yum install --enablerepo=remi --enablerepo=remi-php56 php-fpm
安裝完后再進行查看:

啟動php-fpm
#service php-fpm start
2、配置nginx:
server { listen 80; server_name zabbix.xxx.com; charset utf-8; client_max_body_size 8m; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log error; if ($host = 'zabbix.xxx.com') { rewrite ^/(.*)$ https://zabbix.xxx.com/$1 permanent; } } server { listen 443 ssl; server_name zabbix.xxx.com; index index.php; root /var/www/html/zabbix; include /etc/nginx/ssl.conf; charset utf-8; client_max_body_size 8m; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log error; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
語法檢測無誤后,就可更新nginx配置文件,進行訪問驗證是否配置正確,正確后就可關閉外網9000端口了。