From 40473394c8637163faae9f3590ce27c4b2f01472 Mon Sep 17 00:00:00 2001 From: 21pages Date: Tue, 15 Oct 2024 10:00:13 +0800 Subject: [PATCH] wss login faq Signed-off-by: 21pages --- .../rustdesk-server-pro/faq/_index.en.md | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/content/self-host/rustdesk-server-pro/faq/_index.en.md b/content/self-host/rustdesk-server-pro/faq/_index.en.md index f655a43..7b10bf3 100644 --- a/content/self-host/rustdesk-server-pro/faq/_index.en.md +++ b/content/self-host/rustdesk-server-pro/faq/_index.en.md @@ -364,11 +364,33 @@ Notice: Run `sudo service nginx restart` if you change the `rustdesk.conf` manua #### 7. Login to the web page * Open `https://` in the browser, log in using the default user name "admin" and password "test1234", then change the password to your own. -### 8. Add WebSocket Secure (WSS) support for the id server and relay server to enable secure communication for the web client. +#### 8. Add WebSocket Secure (WSS) support for the id server and relay server to enable secure communication for the web client. -Add the following configuration to the first `server` section of the `/etc/nginx/.../rustdesk.conf` file, then restart the `Nginx` service. +Add the following configuration to the first `server` section of the `/etc/nginx/.../rustdesk.conf` file, then restart the `Nginx` service. Log in to your server from RustDesk public web client at https://rustdesk.com/web. ``` + location / { + + ... + + if ($http_origin ~* (https?://(www\.)?rustdesk\.com)) { + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + } + + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Content-Length' 0; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + return 204; + } + } + location /ws/id { proxy_pass http://localhost:21118; proxy_http_version 1.1; @@ -401,6 +423,23 @@ server { 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/; + + if ($http_origin ~* (https?://(www\.)?rustdesk\.com)) { + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + } + + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' "$http_origin" always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Content-Length' 0; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + return 204; + } } location /ws/id {