Giter Site home page Giter Site logo

origamiofficial / docker-ngrok-plex Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 2.0 82 KB

Run Plex Through Ngrok to Bypass CGNAT or Double-NAT Scenario

Home Page: https://hub.docker.com/r/rlabinc/ngrok-plex

License: MIT License

Dockerfile 18.32% Shell 7.69% Python 73.99%
cgnat ngrok plex plex-api plex-media-server plex-server plexmediaserver port-forward port-forwarding double-nat

docker-ngrok-plex's Introduction

ngrok-plex

Docker Pulls Docker Image Size (tag) Latest Build & Push GitHub Repo stars We Support

ngrok-plex is a command line utility to run Plex through ngrok to bypass CGNAT or Double-NAT scenario.

Note

ngrok free accounts are bandwidth-limited to 1GB per month. You need to have a Pay-as-you-go plan for this project, see pricing here.

Supported Architectures

We utilise the docker buildx for multi-platform awareness. More information is available from docker here.

Simply pulling rlabinc/ngrok-plex:latest should retrieve the correct image for your arch, but you can also pull specific arch images via tags.

The architectures supported by this image are:

Architecture Available Platform
x86-64 linux/amd64
arm64 linux/arm64
armhf linux/arm/v7
i386 linux/386

Usage

You will have to extract the Plex token sets for you and provide it to the CLI. But don't worry, I'll guide you through the entire process.

The Enable Relay must needs to be DISABLED from Settings > Server > Network > Show Advanced > Enable Relay

Extracting the Plex token

  • Go to any media in your Plex library.
  • Go to the Kebab Menu (⋮)
  • Click on Get Info
  • Click on View XML — a new tab should open up.
  • Go to the very end of the URL. You should see a 20 character string after X-Plex-Token=. Copy this string.

Here are the commands you'll need:

docker run -d --network host \
  --name=ngrok-plex \
  -e TZ=Europe/London `#optional` \
  -e PLEX_BaseURL='http://172.17.0.1:32400' `#better to use single quotes` \
  -e PLEX_Token='XXXXXXXXXX' `#better to use single quotes` \
  -e NGROK_Token='XXXXXXXXXX' `#better to use single quotes` \
  rlabinc/ngrok-plex:latest

A cronjob will update new ngrok URL every 2 hours.

Parameters

Container images are configured using parameters passed at runtime (such as those above).

Parameter Function
-e TZ=Europe/London Specify a timezone to use EG Europe/London.
-e PLEX_BaseURL='http://172.17.0.1:32400' Specify Plex URL to use.
-e PLEX_Token='XXXXXXXXXX' Specify Plex token to use.
-e NGROK_Token='XXXXXXXXXX' Specify ngrok token to use.

Cons

  • Client IP will always show as localhost.
  • No bandwidth guarantees.

Contribution

There is no need to update the script version if you have made changes – it will be updated automatically.

Github Repository

https://github.com/origamiofficial/ngrok-plex

Docker Hub

https://hub.docker.com/r/rlabinc/ngrok-plex

Acknowledgements

Script credit goes to @nagleaidan. Special thanks to @Rihcus for fixing many issues.

Warning

Use of this software may constitute a breach in the ngrok Terms of Service. Use at your own risk.

Hits

docker-ngrok-plex's People

Contributors

actions-user avatar dependabot[bot] avatar mend-bolt-for-github[bot] avatar origamiofficial avatar qu1gl3s avatar rlabinc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yawnz rlabinc

docker-ngrok-plex's Issues

[Synology NAS] No longer working with later versions of Plex

This is the what the log throws at me:

ngrok url and ip no port = 3.134.39.220
Traceback (most recent call last):
  File "/root/./ngrok-plex.py", line 72, in <module>
    print("Old settings: " + plex.settings.customConnections)
  File "/usr/local/lib/python3.10/site-packages/plexapi/server.py", line 195, in settings
    self._settings = Settings(self, data)
  File "/usr/local/lib/python3.10/site-packages/plexapi/settings.py", line 20, in __init__
    super(Settings, self).__init__(server, data, initpath)
  File "/usr/local/lib/python3.10/site-packages/plexapi/base.py", line 56, in __init__
    self._loadData(data)
  File "/usr/local/lib/python3.10/site-packages/plexapi/settings.py", line 43, in _loadData
    self._settings[id] = Setting(self._server, elem, self._initpath)
  File "/usr/local/lib/python3.10/site-packages/plexapi/base.py", line 56, in __init__
    self._loadData(data)
  File "/usr/local/lib/python3.10/site-packages/plexapi/settings.py", line 119, in _loadData
    self.enumValues = self._getEnumValues(data)
  File "/usr/local/lib/python3.10/site-packages/plexapi/settings.py", line 142, in _getEnumValues
    return {self._cast(k): v for k, v in [kv.split(':') for kv in enumstr.split('|')]}
  File "/usr/local/lib/python3.10/site-packages/plexapi/settings.py", line 142, in <dictcomp>
    return {self._cast(k): v for k, v in [kv.split(':') for kv in enumstr.split('|')]}
ValueError: not enough values to unpack (expected 2, got 1)

The issue happens with both Synology DS218+ NAS DSM7 package and the Plexinc version for it, if I rollback to 1.29.0.6244 it works again (it's the latest version that works that I'm aware of).

Greetings!

Temporarily disable?

Is there a way to temporarily disable this? e.g. if I switch between ISPs?

I currently have docker-ngrok-plex (and plex) installed on a Synology NAS (thanks to this support).

I have 2 ISPs : one through a 5G SIM which has CGNAT, the other over ADSL, without CGNAT. If I swap to the one without CGNAT, I assume docker-ngrok-plex doesn't 'know' and still routes my Plex remote connections through the ngrok?

If I log into my NAS and simply 'Stop' the Docker container, will that stop the plex traffic going through ngrok?

[How-To] How to set-up on Synology NAS?

Hi Any idea how I can set this up on a Synology NAS?

I'm trying to start with your helpful command template. I want to install it in a subdirectory of /volume1/docker/, but

  1. not sure what should go after the colon in the modified version below:
  2. not sure if I have specified the plex base url correctly: in my case the docker installation is on NAS 192.168.1.12 but the plex server is on NAS 192.168.1.15.
docker run -d \
  --name=ngrok-plex \
  -e TZ=Europe/London 
  -e PLEX_BaseURL='http://192.168.1.15:32400' `my plex server is on a different NAS than the one I run docker on` \
  -e PLEX_Token='myplextoken' 
  -e NGROK_Token='myngroktoken' 
-v /volume1/docker/ngrok-plex: `<---do I need to put something after the colon, here?` \
  rlabinc/ngrok-plex:latest 

Not sure what to do next?

After running the command, I don't get an error, but there's nothing in my /volume1/docker/ngrok-plex directory and the docker log for the container shows:

Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml
tWaiting 5 seconds for ngrok to start up
Traceback (most recent call last):
File "/root/./ngrok-plex.py", line 41, in <module>
ngrokurlclean= ngrokurl.split('//')[-1]
                   ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'split'

As you can tell, I'm not a linux native(!), but would appreciate any help you can give

Volume of data

How much data goes through ngrok for ngrok-docker--plex to work? Is it basically the amount of data streamed from plex to the remote device?

I received notice from ngrok:
"
_We will be enforcing our published outgoing bandwidth limits beginning on January 23, 2024. Our records indicate that the free account connected to this email has exceeded our outgoing bandwidth limit of 1GB per month, over the last 3 months.

Beginning on January 23, 2024, free accounts that transmit >1GB of data will be placed on hold until the next billing cycle (for free accounts, billing cycles are tied to calendar months)._ "

Unable to connect.

Please see the log file below. This container was working fine until I attempted to use the docker gui's update feature to update this container. The script seems to be working correctly as it updates the IP in the Plex network section, but I am unable to ping the IP provided by ngrok, or access it via my browser.

Troubleshooting so far:
Deleted and re-downloaded container
Refreshed ngrok token
Ran container with root privilege (to ensure its not a permission error)
Created new mount point for the container (To ensure folder was not permission locked)

I am running the newest version of plex: 1.32.5.7328

My container settings are as such

PATH: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG: C.UTF-8
GPG_KEY: A035C8C19219BA821ECEA86B64E628F8D684696D
PYTHON_VERSION: 3.11.4
PYTHON_PIP_VERSION: 23.1.2
PYTHON_SETUPTOOLS_VERSION: 65.5.1
PYTHON_GET_PIP_URL: https://github.com/pypa/get-pip/raw/0d8570dc44796f4369b652222cf176b3db6ac70e/public/get-pip.py
PYTHON_GET_PIP_SHA256: 96461deced5c2a487ddc65207ec5a9cffeca0d34e7af7ea1afc470ff0d746207
PLEX_BaseURL: http://192.168.40.147:32400
PLEX_Token: xxxx
NGROK_Token: xxxx

---Log---

date stream content
2023/07/24 18:16:57 stdout AttributeError: 'NoneType' object has no attribute 'split'
2023/07/24 18:16:57 stdout ^^^^^^^^^^^^^^
2023/07/24 18:16:57 stdout ngrokurlclean= ngrokurl.split('//')[-1]
2023/07/24 18:16:57 stdout File "/root/./ngrok-plex.py", line 41, in 
2023/07/24 18:16:57 stdout Traceback (most recent call last):
2023/07/24 18:16:52 stdout �[?1049h�[22;0;0t�[?1h�=�[?25l�[H�[2JWaiting 5 seconds for ngrok to start up
2023/07/24 18:16:52 stdout Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml
2023/07/24 18:08:38 stdout New settings: http://18.204.152.241:16423
2023/07/24 18:08:38 stdout Old settings: http://18.204.152.241:15500
2023/07/24 18:08:38 stdout ngrok url and ip no port = 18.204.152.241
2023/07/24 18:08:37 stdout ngrok base url = 2.tcp.ngrok.io
2023/07/24 18:08:32 stdout �[?1049h�[22;0;0t�[?1h�=�[?25l�[H�[2JWaiting 5 seconds for ngrok to start up
2023/07/24 18:08:32 stdout Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml
2023/07/24 18:07:57 stdout New settings: http://18.204.152.241:15500
2023/07/24 18:07:57 stdout Old settings: http://18.204.152.241:16099
2023/07/24 18:07:57 stdout ngrok url and ip no port = 18.204.152.241
2023/07/24 18:07:56 stdout ngrok base url = 0.tcp.ngrok.io
2023/07/24 18:07:51 stdout �[?1049h�[22;0;0t�[?1h�=�[?25l�[H�[2JWaiting 5 seconds for ngrok to start up
2023/07/24 18:07:50 stdout Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml
2023/07/24 17:13:31 stdout New settings: http://18.204.152.241:16099
2023/07/24 17:13:30 stdout Old settings: http://18.204.152.241:16857,http://100.89.180.124:32400
2023/07/24 17:13:30 stdout ngrok url and ip no port = 18.204.152.241
2023/07/24 17:13:30 stdout ngrok base url = 6.tcp.ngrok.io
2023/07/24 17:13:25 stdout �[?1049h�[22;0;0t�[?1h�=�[?25l�[H�[2JWaiting 5 seconds for ngrok to start up
2023/07/24 17:13:24 stdout Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.