add missing cors bypass for RustDesk public web client

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2025-05-14 13:48:35 +08:00
parent de9255699c
commit d50eaa8653
3 changed files with 65 additions and 0 deletions
@@ -450,6 +450,27 @@ server {
If you have previously deployed for web clients and want to use it across all platforms, you need to add `proxy_read_timeout`.
{{% /notice %}}
#### 9. Bypass CORS if using RustDesk public web client `https://rustdesk.com/web`
You need to add below in the `location /` section of the `/etc/nginx/.../rustdesk.conf` to bypass CORS limitation of browsers. Skip this step if you are using your own web client.
```
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;
}
```
### SELinux