Synology NAS Proxy and Emby Configuration

Recently, when using v2rayA on my Synology NAS, I encountered an issue where incorrect time synchronization caused it to stop working properly, which in turn prevented Emby from scraping metadata. Although I don’t know the exact reason, it’s an old problem. The version was very old, and I was using a Docker image from a third-party application store; currently, Docker can’t pull images via direct connection either. Here is my experience with solving this:

  1. Reinstall v2rayA
  2. Configure the Docker version of Emby.

Reference Websites:

Linux Backup Installation Method - v2rayA

XTLS/Xray-core: Xray, Penetrates Everything. Also the best v2ray-core. Where the magic happens. An open platform for various uses.

Implementing Transparent Proxy on Synology - v2rayA

sjtuross/syno-iptables: Some missing iptables modules for Synology

Setting up Proxy for Container Manager (Docker) on Synology DSM 7.2 - CSDN Blog

v2rayA

According to the official v2rayA documentation, there is no specially adapted version for Synology, so we use the generic binary file for installation. Since we cannot pull files from GitHub over a direct connection, we download it on our computer and transfer it to the NAS. In addition, the installation steps below are actually slightly different from the official documentation.

  1. Copy v2rayA and xray

    1
    2
    3
    4
    
    cp v2raya_linux_x64 /usr/local/bin/v2raya
    cp xray /usr/local/bin/
    chmod +x /usr/local/bin/v2raya
    chmod +x /usr/local/bin/xray
    
  2. Copy the GFWList proxy rule files included with xray: geoip.dat and geosite.dat

    1
    2
    3
    
    cd /usr/local/share
    mkdir xray
    cp .../g* xray
    
  3. Modify the service configuration file

    1
    
    sudo vi /etc/systemd/system/v2raya.service
    

    The content was generated by ChatGPT combined with the official documentation:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    
    [Unit]
    Description=v2rayA Service
    After=network.target
    
    [Service]
    Type=simple
    User=root
    Environment="V2RAYA_CONFIG=/usr/local/etc/v2raya"
    Environment="V2RAYA_LOG_FILE=/tmp/v2raya.log"
    Environment="XRAY_LOCATION_ASSET=/usr/local/share/xray"
    ExecStart=/usr/local/bin/v2raya --passcheckroot
    Restart=on-failure
    LimitNOFILE=1000000
    
    [Install]
    WantedBy=multi-user.target
    
  4. Activate v2rayA. According to the official documentation, run it as a service

    1
    2
    
    sudo systemctl start v2raya
    sudo systemctl status v2raya
    

    Configure it to start up automatically on boot. Theoretically, the configuration is complete after this step. Along the way, I also solved the issue of transparency proxy not working on Synology.

    1
    2
    
    sudo systemctl enable v2raya
    sudo systemctl is-enabled v2raya
    
  5. Activate Transparent Proxy

    archkerneliptables versionsystem modelplatform version
    apollolake4.4.180+v1.8.3DS918+7.0.1-42218
    apollolake4.4.59+v1.6.0DS918+6.2.3-25426
    broadwell3.10.105v1.6.0DS3617xs6.2.3-25426
    bromolow3.10.105v1.6.0DS3615xs6.2.3-25426
    geminilake4.4.180+v1.8.3DS920+7.1-42661
    geminilake4.4.302+v1.8.3DS220+7.2-64570

    Due to the characteristics of the Synology system, first determine the architecture based on your model, then select the appropriate files for your machine from the downloaded modules from the GitHub repository (for example, my DS224 is geminilake).

    Upload the corresponding ko modules to /lib/modules/, and upload the corresponding so modules to /usr/lib/iptables/, and that’s it.

    Run sudo -i and then run the following insmod commands to attempt loading the ko kernel modules. Because the modules depend on each other, they must be loaded in a specific order.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    insmod /lib/modules/nfnetlink.ko
    insmod /lib/modules/ip_set.ko
    insmod /lib/modules/ip_set_hash_ip.ko
    insmod /lib/modules/xt_set.ko
    insmod /lib/modules/ip_set_hash_net.ko
    insmod /lib/modules/xt_mark.ko
    insmod /lib/modules/xt_connmark.ko
    insmod /lib/modules/xt_comment.ko
    insmod /lib/modules/xt_TPROXY.ko
    insmod /lib/modules/xt_socket.ko
    insmod /lib/modules/iptable_mangle.ko
    insmod /lib/modules/textsearch.ko
    insmod /lib/modules/ts_bm.ko
    insmod /lib/modules/xt_string.ko
    
    insmod /lib/modules/nf_nat_ipv6.ko
    insmod /lib/modules/nf_nat_masquerade_ipv6.ko
    insmod /lib/modules/ip6t_MASQUERADE.ko
    insmod /lib/modules/ip6table_nat.ko
    insmod /lib/modules/ip6table_raw.ko
    insmod /lib/modules/ip6table_mangle.ko
    

    However, after a system reboot, the modules need to be reloaded, so generate a script with the above content at /usr/local/bin/load_v2raya_mods.sh.

    Then restart the v2rayA service:

    1
    
    sudo systemctl restart v2raya
    

Emby

After configuring v2rayA, even though I used the method of modifying the configuration file, Emby’s traffic still couldn’t successfully pass through v2rayA. After various fruitless attempts to modify the IP configuration, it naturally occurred to me that this was caused by Docker running as a host service.

After modifying the configuration on v2rayA multiple times, I finally found that enabling the transparent proxy solved the problem, and it also fixed the issue of being unable to connect to the Docker repository. But a bigger problem arose: enabling the transparent proxy caused all external network access to fail (fortunately, local network connections still worked). I think “transparent proxy” can be understood as a “global proxy”.

For the issue of setting up a proxy specifically for Docker (Container Manager), please refer to the links in the preface.

  1. Select Emby in “Images” and run it. Add the path to the media library in “Volume Settings”, add three environment variables in “Environment”, and select host mode in “Network”:

    1
    2
    3
    
    HTTP_PROXY = http://127.0.0.1:20171
    HTTPS_PROXY = http://127.0.0.1:20171
    NO_PROXY = localhost,127.0.0.1
    
  2. Complete the basic setup, install the previous anime-related plugins, and the scraping was successful.

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy