Skip to content

Web Client V2 Preview Document

乐 edited this page Dec 9, 2024 · 4 revisions

下面的配置都是以docker方式为例,镜像为官方s6镜像rustdesk/rustdesk-server-s6:latest

HTTP

http模式比较简单,下面是docker-compose示例

networks:
  rustdesk-net:
    external: false
services:
  rustdesk-server:
    container_name: rustdesk-server
    ports:
      - 21115:21115
      - 21116:21116
      - 21116:21116/udp
      - 21117:21117
      - 21118:21118
      - 21119:21119
    image: rustdesk/rustdesk-server-s6:latest
    environment:
      - RELAY=<server>:21117
      - ENCRYPTED_ONLY=1
    volumes:
      - /data/rustdesk/server:/data
    restart: unless-stopped
  rustdesk-api:
    container_name: rustdesk-api
    ports:
      - 21114:21114
    image: lejianwen/rustdesk-api
    environment:
      - TZ=Asia/Shanghai
      - RUSTDESK_API_RUSTDESK_ID_SERVER=<server>:21116
      - RUSTDESK_API_RUSTDESK_RELAY_SERVER=<server>:21117
      - RUSTDESK_API_RUSTDESK_API_SERVER=http://<server>:21114
      - RUSTDESK_API_RUSTDESK_KEY=<key>
    volumes:
      - /data/rustdesk/api:/app/data 
    networks:
      - rustdesk-net
    restart: unless-stopped

pc 客户端

image

HTTPS

此种情况下一般都配置域名,下面都以api.example.com为例

dokcer-compose 配置

networks:
  rustdesk-net:
    external: false
services:
  rustdesk-server:
    container_name: rustdesk-server
    ports:
      - 21115:21115
      - 21116:21116
      - 21116:21116/udp
      - 21117:21117
      - 21118:21118
      - 21119:21119
    image: rustdesk/rustdesk-server-s6:latest
    environment:
      - RELAY=api.example.com
      - ENCRYPTED_ONLY=1
    volumes:
      - /data/rustdesk/server:/data
    restart: unless-stopped
  rustdesk-api:
    container_name: rustdesk-api
    ports:
      - 21114:21114
    image: lejianwen/rustdesk-api
    environment:
      - TZ=Asia/Shanghai
      - RUSTDESK_API_RUSTDESK_ID_SERVER=api.example.com
      - RUSTDESK_API_RUSTDESK_RELAY_SERVER=api.example.com
      - RUSTDESK_API_RUSTDESK_API_SERVER=https://api.example.com
      - RUSTDESK_API_RUSTDESK_KEY=<key>
    volumes:
      - /data/rustdesk/api:/app/data 
    networks:
      - rustdesk-net
    restart: unless-stopped

使用443端口

这种情况下websocket会使用443,必须配置反代,以nginx为例

下面这个配置来自官方文档

server {
    server_name <YOUR_DOMAIN>;
    location / {
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:21114/;
    }

    location /ws/id {
        proxy_pass http://localhost:21118;
        proxy_http_version 1.1;
        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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /ws/relay {
        proxy_pass http://localhost:21119;
        proxy_http_version 1.1;
        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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/<YOUR_DOMAIN>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/<YOUR_DOMAIN>/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = <YOUR_DOMAIN>) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name <YOUR_DOMAIN>;
    listen 80;
    return 404; # managed by Certbot
}

同时PC客户端的配置中,不要填端口

image

效果图

image

image

使用非443端口,比如4443

websocket会使用自定义端口,一般是21118,21119,反代的配置需要改变,需要反代21118,21119的端口

此时可能遇到2111821119的端口占用问题,因为docker-compose中已经暴露了21118,21119 所以修改docker-compose的配置,可以选择不映射端口,然后反代中指定容器的名和端口,也可以修改映射的端口

下面是例子

我这里选择修改映射的端口

      - 21108:21118
      - 21109:21119
server {
    server_name <YOUR_DOMAIN>;
    location / {
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:21114/;
    }

    listen 4443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/<YOUR_DOMAIN>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/<YOUR_DOMAIN>/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    server_name <YOUR_DOMAIN>;
    location / {
        proxy_pass http://localhost:21108;
        proxy_http_version 1.1;
        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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }


    listen 21118 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/<YOUR_DOMAIN>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/<YOUR_DOMAIN>/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    server_name <YOUR_DOMAIN>;
    location / {
        proxy_pass http://localhost:21109;
        proxy_http_version 1.1;
        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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }


    listen 21119 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/<YOUR_DOMAIN>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/<YOUR_DOMAIN>/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}


PC客户端中,需要填上端口

image

效果图

image

image