分布式部署文档 - nginx 代理部署
- 系统: CentOS 7
- IP: 192.168.100.100
- # 安装 nginx
- $ vi /etc/yum.repos.d/nginx.repo
-
- [nginx]
- name=nginx repo
- baseurl=http://nginx.org/packages/centos/7/$basearch/
- gpgcheck=0
- enabled=1
-
- # 非 Centos7 请参考 http://nginx.org/en/linux_packages.html#stable
- # 配置 Nginx
- $ vi /etc/nginx/nginx.conf
-
- user nginx;
- worker_processes auto;
-
- error_log /var/log/nginx/error.log warn;
- pid /var/run/nginx.pid;
-
-
- events {
- worker_connections 1024;
- }
-
- stream {
- log_format proxy '$remote_addr [$time_local] '
- '$protocol $status $bytes_sent $bytes_received '
- '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
-
- access_log /var/log/nginx/tcp-access.log proxy;
- open_log_file_cache off;
-
- upstream MariaDB {
- server 192.168.100.10:3306;
- server 192.168.100.11:3306 backup; # 多节点
- server 192.168.100.12:3306 down; # 多节点
- # 这里是 Mariadb 的后端ip
- }
-
- upstream cocossh {
- server 192.168.100.40:2222;
- server 192.168.100.40:2223; # 多节点
- # 这里是 coco ssh 的后端ip
- least_conn;
- }
-
- server {
- listen 3306;
- proxy_pass MariaDB;
- proxy_connect_timeout 1s; # detect failure quickly
- }
-
- server {
- listen 2222;
- proxy_pass cocossh;
- proxy_connect_timeout 1s; # detect failure quickly
- }
- }
-
- http {
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- 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;
-
- keepalive_timeout 65;
-
- # 关闭版本显示
- server_tokens off;
-
- include /etc/nginx/conf.d/*.conf;
- }
- # nginx 测试并启动, 如果报错请按报错提示自行解决
- $ nginx -t
- $ systemctl start nginx
-
- # 访问 http://192.168.100.100
- # 默认账号: admin 密码: admin 到会话管理-终端管理 接受 Coco Guacamole 等应用的注册
- # 测试连接
- $ ssh -p2222 admin@192.168.100.100
- $ sftp -P2222 admin@192.168.100.100
- 密码: admin
-
- # 如果是用在 Windows 下, Xshell Terminal 登录语法如下
- $ ssh admin@192.168.100.100 2222
- $ sftp admin@192.168.100.100 2222
- 密码: admin
- 如果能登陆代表部署成功
-
- # sftp默认上传的位置在资产的 /tmp 目录下
- # windows拖拽上传的位置在资产的 Guacamole RDP上的 G 目录下