下载compose文件:
- git clone https://github.com/zabbix/zabbix-docker.git
- git checkout 6.4
修改compose文件,修改映射到宿主的端口,不要冲突
- vim docker-compose_v3_alpine_mysql_latest.yaml
- ---------------------------------
- zabbix-web-nginx-mysql:
- image: zabbix/zabbix-web-nginx-mysql:alpine-6.4-latest
- ports:
- - "18081:8080" #18081就是暴露的端口
- #- "443:8443"
- ----------------------------------
- docker compose -f ./docker-compose_v3_alpine_mysql_latest.yaml up -d
修改容器内nginx配置,让其支持远端ip获取:
- docker exec -it zabbix-zabbix-web-nginx-mysql-1 bash
- cd /etc/zabbix/
- #server 下粘贴如下内容
- set_real_ip_from 0.0.0.0/0;
- real_ip_header X-Real-IP;
- real_ip_recursive on;
- nginx -s reload
设置第一层nginx二级目录代理
- location ^~ /zabbix/ {
- proxy_pass http://127.0.0.1:18081;
- rewrite "/zabbix/(.*)$" /$1 break;
- proxy_redirect ~^/(.*) https://$http_host/zabbix/$1;
- proxy_http_version 1.1;
- proxy_buffering off;
- proxy_request_buffering off;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
-
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
- sub_filter_types *;
- sub_filter_once off;
- sub_filter '/js/' '/zabbix/js/';
- sub_filter '/assets/' '/zabbix/assets/';
- }
如果sub_filter无效,可能是gzip压缩的锅,添加
proxy_set_header Accept-Encoding '';