lantongxue / rustdesk-api-server-pro

🚀This is an open source Api server based on the open source RustDesk client, the implementation of the client all Api interfaces, and provides a Web-UI for the management of data.
GNU Affero General Public License v3.0
16 stars 2 forks source link

Reverse Proxy Settings #2

Closed AttNet closed 1 day ago

AttNet commented 6 days ago

Thanks for this project. With the new documentation i was able to compile the backend and to build the frontend. I created the nginx server config and set the right root folder... I can see the login screen, but i get the error message 'api.Network error' I think, my reverse proxy configuration is wrong. Can you please add the information, what is needed here ? at the moment i forward location /api/ and /admin/ to the http:/127.0.0.1:8080/api/ and http:/127.0.0.1:8080/admin/ but, for the frontend this is not working.

What is the needed reverse proxy configuration to bind the frontend to the backend ?

Best regards, AttNet

lantongxue commented 5 days ago

@AttNet Here's my backend reverse proxy configuration for you to refer to:

You need to re-pull the code to build the frontend


#PROXY-START /api for rustdesk client

location ^~ /api
{
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host 127.0.0.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    add_header X-Cache $upstream_cache_status;
}
#PROXY-END/

#PROXY-START /admin for web-ui

location ^~ /admin
{
    proxy_pass http://127.0.0.1:8080/admin;
    proxy_set_header Host 127.0.0.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    add_header X-Cache $upstream_cache_status;
}
#PROXY-END/
AttNet commented 5 days ago

Thanks for your respnse. I build all new from scratch, but the result is the same... Now i see the error 'api.the backend error'

Here is my complete nginx config, can you tell me the problem please ... ? I added the connection_upgrade map and hope this is correct.

`server { server_name rdc.mydomain.de; listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/rdc.mydomain.de/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/rdc.mydomain.de/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

location / {
  root /opt/rustdesk-api-server-pro/soybean-admin/dist/;
  index index.html index.htm;
  try_files $uri $uri/ /index.html;
}

#PROXY-START /api for rustdesk client

location ^~ /api
{
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host 127.0.0.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    add_header X-Cache $upstream_cache_status;
}
#PROXY-END/

#PROXY-START /admin for web-ui

location ^~ /admin
{
    proxy_pass http://127.0.0.1:8080/admin;
    proxy_set_header Host 127.0.0.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    add_header X-Cache $upstream_cache_status;
}
#PROXY-END/

}

map $http_upgrade $connection_upgrade { default upgrade; '' close; } `

lantongxue commented 5 days ago

You need re-build frontend :)

AttNet commented 5 days ago

I rebuilded both complete. Does the build process of the frontend needs information of the nginx configuration file ? I can not build the fron/backend at the real virtual maschine (only 1GB Memory and the build process crashes). So i build it on a lokal virtual mashine and transfer the complete directory to the online one. Both are debian 12 vm's.

lantongxue commented 5 days ago
  1. Did you re-pull the latest code?
  2. Build without nginx configuration