Skip to content

Cannot connect to Aria2 RPC when working behind Nginx #733

@johnnysong-cc

Description

@johnnysong-cc

Running Context

Aria2 RPC Server is running on 192.168.1.99:6800
AriaNg client is running on 192.168.1.254:6880
They work fine together.
However when I tried to put AriaNg behind Nginx reverse proxy with the following configuration:

stream {
  map $ssl_preread_server_name $backend_name {
    aria.mydomain.com aria;
  }
  upstream aria{
    server 127.0.0.1:26880;
  }
}

http {
  server {
    listen 26880 ssl;
    server_name aria.mydomain.com;

    ssl_certificate fullchain.cer;
    ssl_certificate_key aria.mydomain.com.key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_session_timeout 5m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;
    # ssl_verify_client off;
    # ssl_handshake_timeout 30s;

    location / {
      proxy_pass http://192.168.1.254:6880/;
      proxy_set_header Host $host;
      proxy_set_header Origin 192.168.1.254;
      proxy_set_header Referer 192.168.1.254;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }  
}

Symptom

When accessing via "https://aria.mydomain.com" in the browser, the AriaNg client is still accessible but it can't connect to the RPC server via 192.168.1.99:6800 anymore.

Here are the problems beyond my reach

  • On the RPC Server settings, "http" and "websocket" can't be used and options were confined to "https" and "wss". However, I tried to use the certificates for "aria.mydomain.com" issued by LetsEncrypt with Aria2 RPC Server but it doesn't accept them.

    enable-rpc=true
    rpc-allow-origin-all=true
    rpc-listen-all=true
    rpc-certificate=D:\aria2-1.36.0\fullchain.cer
    rpc-private-key=D:\aria2-1.36.0\aria.mydomain.com.key
    rpc-secure=true
    
  • There are many jsonrpc errors in the Network tab of Chrome DevTools. I have tried to use proxy_set_header to change the Origin and Referer headers as shown in the configuration but they remain unchanged as "https://aria.mydomain.com"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions