反向代理

    • rdp 协议复制粘贴需要部署可信任的 ssl 证书
    • 通过 https 协议访问就能在 rdp 资产里面使用复制粘贴
    • 遵循 Mozilla SSL Configuration Generator 建议
    • 将证书放到 /opt/jumpserver/config/nginx/cert 里面
    1. ## Nginx 配置, USE_LB=1 表示开启, 为 0 的情况下, HTTPS_PORT 定义不生效
    2. HTTP_PORT=80
    3. SSH_PORT=2222
    4. RDP_PORT=3389
    5. USE_LB=1 # 1 表示开启此选项
    6. HTTPS_PORT=443 # 对外 https 端口
    1. # Todo: May be can auto discovery
    2. upstream http_server {
    3. sticky name=jms_route;
    4. server web:80;
    5. # server HOST2:80; # 多节点
    6. }
    7. server {
    8. listen 80;
    9. server_name demo.jumpserver.org; # 自行修改成你自己的域名
    10. return 301 https://$server_name$request_uri;
    11. }
    12. server {
    13. listen 443 ssl;
    14. server_name demo.jumpserver.org; # 自行修改成你自己的域名
    15. server_tokens off;
    16. ssl_certificate_key cert/server.key; # 修改 server.crt 为你的证书密钥文件, 不要改路径 certs/
    17. ssl_session_timeout 1d;
    18. ssl_session_tickets off;
    19. ssl_protocols TLSv1.1 TLSv1.2;
    20. ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    21. ssl_prefer_server_ciphers off;
    22. add_header Strict-Transport-Security "max-age=63072000" always;
    23. client_max_body_size 5000m; # 上传文件大小限制
    24. location / {
    25. proxy_pass http://http_server;
    26. proxy_buffering off;
    27. proxy_request_buffering off;
    28. proxy_http_version 1.1;
    29. proxy_set_header Host $host;
    30. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    31. proxy_set_header Upgrade $http_upgrade;
    32. proxy_set_header Connection $http_connection;
    33. proxy_ignore_client_abort on;
    34. proxy_connect_timeout 600;
    35. proxy_send_timeout 600;
    36. proxy_read_timeout 600;
    37. send_timeout 6000;
    38. }
    39. }
    • 适合上层还有统一对外出口的反向代理服务器
    • 属于多层 nginx 反向代理
    • 每一层都需要设置 websocket 长连接
    1. vi /etc/nginx/conf.d/jumpserver.conf
    1. server {
    2. server_name demo.jumpserver.org; # 自行修改成你的域名
    3. return 301 https://$server_name$request_uri;
    4. }
    5. server {
    6. listen 443 ssl;
    7. server_name demo.jumpserver.org; # 自行修改成你的域名
    8. ssl_certificate sslkey/1_jumpserver.org_bundle.crt; # 自行设置证书
    9. ssl_certificate_key sslkey/2_jumpserver.org_bundle.key; # 自行设置证书
    10. ssl_session_timeout 1d;
    11. ssl_session_cache shared:MozSSL:10m;
    12. ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    13. ssl_prefer_server_ciphers off;
    14. ssl_protocols TLSv1.1 TLSv1.2;
    15. add_header Strict-Transport-Security "max-age=63072000" always;
    16. client_max_body_size 4096m; # 录像及文件上传大小限制
    17. location / {
    18. # 这里的 ip 是后端 JumpServer nginx 的 ip
    19. proxy_pass http://192.168.244.144;
    20. proxy_http_version 1.1;
    21. proxy_buffering off;
    22. proxy_request_buffering off;
    23. proxy_set_header Upgrade $http_upgrade;
    24. proxy_set_header Connection "upgrade";
    25. proxy_set_header X-Real-IP $remote_addr;
    26. proxy_set_header Host $host;
    27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    28. }
    • 需要注意 websocket 长连接设置即可
    • 需要注意 session 问题