Skip to content

HTTP Reverse Proxy

lejianwen edited this page Dec 10, 2024 · 1 revision

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

  1. docker-compose配置

    • 上面的<server>是你的域名或者ip,根据实际情况修改
    • 如果nginx不是用docker方式,根据情况修改映射的端口并修改反向代理配置
     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>
           - ENCRYPTED_ONLY=1
         volumes:
           - /data/rustdesk/server:/root
         networks:
           - rustdesk-net
         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> 
           - RUSTDESK_API_RUSTDESK_RELAY_SERVER=<server> 
           - RUSTDESK_API_RUSTDESK_API_SERVER=http://<server> 
           #- RUSTDESK_API_RUSTDESK_KEY=<key>
         volumes:
           - /data/rustdesk/api:/app/data #将数据库挂载
           - /data/rustdesk/server:/app/conf/data #挂载key文件到api容器,可以不用使用 RUSTDESK_API_RUSTDESK_KEY
         networks:
           - rustdesk-net
         restart: unless-stopped
         depends_on:
           - rustdesk-server
       nginx:
         container_name: rustdesk-nginx
         image: nginx:latest
         ports:
           - 80:80
           - 443:443
           - 21118:21118
           - 21119:21119
         volumes:
           - /data/rustdesk/nginx/conf.d:/etc/nginx/conf.d
         networks:
           - rustdesk-net
         restart: unless-stopped
         depends_on:
           - rustdesk-api
           - rustdesk-server
  2. nginx反向代理配置

    • 这里的<server>是你的域名或者ip,根据实际情况修改,rustdesk-apirustdesk-serverdocker-compose 中的服务名,如果非docker方式,根据情况修改
    server {
        server_name <server>;
        listen 80;
        location / {
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://rustdesk-api:21114/;
        }
    }
    
    server {
        listen 21118; 
        server_name <server>;
        location / {
            proxy_pass http://rustdesk-server: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;
        }
    }
    
    server {
        listen 21119;
        server_name <server>;
        location / {
            proxy_pass http://rustdesk-server: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;
        }
    }
    
Clone this wiki locally