启动
docker run -it --name lv_ocr --privileged=true --restart=always --net=host -v $(pwd)/config/nginx.conf:/etc/nginx/nginx.conf -v $(pwd)/config/conf.d:/etc/nginx/conf.d -d harbor.jettech.com/jettechtools/nginx:1.21.4
[root@it4it-prd-99 config]# ls
conf.d nginx.conf
[root@it4it-prd-99 config]# tree
.
├── conf.d
│ ├── http
│ │ ├── server
│ │ │ ├── captcha_aarch64.conf
│ │ │ └── captcha_x86.conf
│ │ └── stream
│ │ ├── captcha_aarch64.conf
│ │ └── captcha_x86_64.conf
│ └── tcp
│ ├── server
│ │ └── mysql.conf
│ └── stream
│ └── mysql.conf
└── nginx.conf
[root@it4it-prd-99 config]# cat nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {worker_connections 1024;
}
http {log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 2048;include /etc/nginx/mime.types;default_type application/octet-stream;include /etc/nginx/conf.d/http/stream/*.conf;include /etc/nginx/conf.d/http/server/*.conf;
}
stream {include /etc/nginx/conf.d/tcp/stream/*.conf;include /etc/nginx/conf.d/tcp/server/*.conf;
}
http:
[root@it4it-prd-99 config]# cat conf.d/http/server/captcha_x86.conf
server {listen 80;location / {proxy_set_header X-Forwarded-Host $host;proxy_set_header Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 3000m;proxy_buffer_size 63k;proxy_buffers 1024 64k;client_body_buffer_size 512m;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;proxy_pass http://captcha_x86;}location /status {stub_status on;access_log off;}}
[root@it4it-prd-99 config]# cat conf.d/http/stream/captcha_x86_64.conf
upstream captcha_x86 {least_conn; #使用最少连接调度算法#ip_hash;#random;server 192.168.0.7:52000 weight=1 max_fails=5 fail_timeout=2;#server 192.168.0.8:9999 weight=1 max_fails=5 fail_timeout=2 backup; #备份机使用,所有宕机时候使用
}
tcp:
[root@it4it-prd-99 config]# cat conf.d/tcp/server/mysql.conf
server {listen 23306;proxy_connect_timeout 10s;proxy_timeout 200s;proxy_pass mysql;
}
[root@it4it-prd-99 config]# cat conf.d/tcp/stream/mysql.conf
upstream mysql {server 172.16.10.57:53306;
}