测试环境Portal页面整合
背景
由于公司POC环境比较多,2个人负责运维,多个人负责开发以及集成测试,管理页面也相对比较多,针对如下情况,进行了web控制台管理页面的整合。
改造思路
1、NGINX通过server_name进行区分主机
2、server那么规划:$app_name.$project_name.xxx-poc.com // xxx为公司名称缩写
3、每个项目新增域名的时候,脚本自动感知nginx重启,diff nginx配置文件,将新增的domain注册到公司dns上面
4、nginx前置通过F5进行负载,健康检查;NGINX后端根据业务需求进行负载均衡的配置
4、开发、运维、测试人员即可连接VPN、公司内网进行环境的访问
优点:
1、环境多的时候无需记忆多个ip、port对应的程序
2、根据域名区分,方便管控
配置方式
NGINX主文件配置
### Nginx主配置
# worker_process启动用户配置
#user nginx;
# worker_process数配置
worker_processes auto;
worker_rlimit_nofile 65535;
# 错误日志存储以及要保存的错误日志级别【debug|info|notice|warn|error|crit|alert|emerg】
error_log /var/log/nginx/error.log warn;
#error_log logs/error.log error;
#error_log logs/error.log notice;
#error_log logs/error.log info;
# nginx进程pid文件存储
pid /run/nginx.pid;
# epoll是多路复用IO(I/O Multiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以提升nginx性能
# 单个worker_process进程的最大并发连接数,根据CPU性能和业务需求而定
events {
use epoll;
worker_connections 65535;
}
### http块配置
http {
include mime.types; #设定mime类型,类型由mime.type文件定义;
#默认配置,这里表示引用context-type的配置文件。如需要添加新的类型,手动在此文件中添加即可
default_type application/octet-stream; #此参数为默认context-type类型定义
keepalive_timeout 65; #会话超时时间
#access_log logs/access.log main; #主日志文件,不建议在这里配置,因为这里日志无法进行按照日期切割;
log_format main '$remote_addr || $remote_user [$time_local] || "$request" || $status || $body_bytes_sent || "$http_referer" || "$http_user_agent" || "$http_x_forwarded_for" || $upstream_status || $upstream_addr || "$upstream_cache_status" || $request_time $upstream_response_time'; #日志格式定义
sendfile on; #开启调用linux的sendfile功能,提高文件传输效率
server_tokens off; #隐藏nginx版本显示
include conf.d/*.conf; #引用所有的虚拟主机文件
}
mime.types
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/x-nokia-widget wgz;
application/vnd.android.package-archive apk;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
虚拟主机配置文件
server {
server_name grafana.ops.xxx-poc.com; # ops 是运维管理人员的web页面
client_max_body_size 5g;
client_body_buffer_size 10240k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
#X-Forwarded-For
#下面配置用于切割日志文件使用
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
}
access_log grafana_access-$year$month$day.log main;
location / {
proxy_pass http://192.168.110.137:3000/;
}
location = /basic_status {
stub_status;
}
}
DNS对接
1、并非公用,为自研DNS,无参考意义
验证方式
ping 测试
ail@MacBook-Pro ~ % ping -c 1 nacos.xxx.xxx-poc.com
PING nacos.xmbank.xxx-poc.com (192.168.110.138): 56 data bytes
ail@MacBook-Pro ~ % ping -c 1 grafana.ops.xxx-poc.com
PING grafana.ops.xxx-poc.com (192.168.110.138): 56 data bytes
ail@MacBook-Pro ~ % ping -c 1 kibana.ops.xxx-poc.com
PING kibana.ops.xxx-poc.com (192.168.110.138): 56 data bytes
ail@MacBook-Pro ~ %