Crivella / ocr_translate

Django based web server for running OCR + Translation of incoming images
GNU General Public License v3.0
18 stars 2 forks source link

Access from other devices on local network #30

Open Appex213 opened 3 weeks ago

Appex213 commented 3 weeks ago

Is there a way to access the server from outside of localhost?

I'm using the release version for windows and can't get the server to run with an address that isn't localhost to get the server to be visible on the local network. Is there something I'm missing?

Crivella commented 3 weeks ago

There are 2 sides to this problem:

On the first part if you are using the EXE, the script running the server is baked into the EXE and it is being run by binding the server to local host. You would need to either follow the instruction on the docs (https://crivella.github.io/ocr_translate/running/from_github.html) and substitute the last command to execute by binding to 0.0.0.0 -> python manage.py runserver 0.0.0.0:PORT Or use the docker container as there gunicorn is already set to bind to 0.0.0.0 (https://github.com/Crivella/ocr_translate/blob/95b26839d9d95103214caee419a33cb7b2bbad9f/start-server.sh#L44) (you will also have) to make sure that your container is reachable from outside at that point

On the second part, again if you are using the bundled EXE i am not sure there is a non hacky way of changing the line to add whatever server you need to allow connections from (https://github.com/Crivella/ocr_translate/blob/95b26839d9d95103214caee419a33cb7b2bbad9f/mysite/settings.py#L106). While following the instruction you can just edit that line to add the host you want to allow, (and in case you are using docker you will need to go into the running container docker exec -it CONTAINER_NAME /bin/bash and edit it from inside and restart the server.

NOTE binding to 0.0.0.0 in general means you allow connections from every interface on your device (eg etherneth wifi, loop localhost and so on), so that address is not related to the device you want to connect from, but to which virtual/physical interface you want to allow to access the server

PS: there could also be possible that if you have windows firewall on, you will have to whitelist whatever app is hosting the server for it to be accessed from ourside

Let me know if this works for you

Crivella commented 3 weeks ago

PS if there is request for this i might check on a few way to make this easier to do also using the EXE, but consider that right now the server is not build to handle large volumes (using more dedicated services to enable this would require complicating the installation a lot, eg people would need to set up and configure those services beside running the EXE), in case of multiple users there would also be the problem of who controls what model are loaded