Coder Social home page Coder Social logo

iobroker.proxy's Introduction

Logo

ioBroker.proxy

Number of Installations Number of Installations NPM version Downloads Tests

NPM

Usage

Allows to access defined URLs or local files via one web server.

Specified routes will be available under http://ip:8082/proxy.0/context/.... Of course port, protocol, proxy.0, can variate depends on settings.

Configuration

  • Extend WEB adapter: For which web instance will active this proxy.
  • Route path: Path for proxy. If "/proxy.0", so the routes will be available under http://webIP:8082/proxy.0/...
  • Error timeout(ms): Minimal interval between retries if the requested resource was unavailable or returned error.
  • Use simple proxy: in this case the very simple but robust method will be used. It is not suitable for web sockets or POST request. Use this method if you have some issues with WEB Instance or socket.io communication.

Sample settings

Context URL Description
admin/ http://localhost:8081 access to admin page
router/ http://192.168.1.1 access to local router
cam/ http://user:[email protected] access to webcam (e.g. call http://ip:8082/proxy.0/cam/web/snapshot.jpg)
dir/ /tmp/ access to local directory "/tmp/"
dir/ tmp/ access to local directory "/opt/iobroker/tmp"
file.jpg /tmp/picture.jpg access to local file "/tmp/picture.jpg"

Not all devices can be accessed via proxy.

Some devices wants to be located in the root http://ip/ and cannot run under http://ip/proxy.0/context/.

You can read more about context here

Additionally the user can define the route path for proxy requests.

Changelog

1.3.2 (2022-10-01)

  • (Apollon77) Allow to also proxy files directly

1.3.1 (2022-06-02)

  • (Apollon77) Revert the automatic WS upgrade call added in 1.3.0 because produced sometimes issues with websocket connections

1.3.0 (2022-05-30)

  • (Apollon77) Allow to configure the maximum parallel requests by route and/or globally. Default is 10 as of now too
  • (Apollon77) Try to prevent crashes by socket errors

1.2.2 (2021-03-07)

  • (Apollon77) Fallback to "application/octet-stream" when mime type for a file could not be determined
  • (Apollon77) Cut filenames when looking them up in the filesystem if "?" or "#" are included

1.2.1 (2020-04-14)

  • (bluefox) Corrected error with access to local files

1.2.0 (2020-03-08)

  • (Apollon77) update dependencies

1.1.1 (2019-07-02)

  • (bluefox) Implemented simple proxy to eliminate socket.io problem

1.0.3 (2018-07-14)

  • (bluefox) Newer mime version used

1.0.2 (2018-06-30)

  • (bluefox) URI was decoded for usage of special chars in password and login

1.0.1 (2018-03-01)

  • (bluefox) Fixed error: after 10 timeouts the web cam was never reachable
  • (bluefox) Ready for Admin3

1.0.0 (2017-10-09)

  • (bluefox) do not allow the error generation to fast

0.2.0 (2017-03-13)

  • (bluefox) fix run-mode

0.0.1 (2017-01-09)

  • (bluefox) initial commit

License

The MIT License (MIT)

Copyright (c) 2017-2022 bluefox [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

iobroker.proxy's People

Contributors

apollon77 avatar dependabot[bot] avatar germanbluefox avatar giermann avatar johnnybyzhang avatar ldittmar81 avatar lgtm-migrator avatar unclesamswiss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

iobroker.proxy's Issues

Web- Service restart on changeView

Good day,

I have the phenomenon that my web.1 adapter restarts constantly when I trigger a changeView via script.
After some searching, I strongly suspect that the problem is related to the proxy adapter.
If this is not the case, I am happy to be proven wrong. Maybe you have another idea.

As soon as this is active, the web.1 adapter hangs and restarts often.
I can see the following message in the log:
`

web.1 2022-01-17 17:13:50.008 error Exception-Code: ECONNRESET: read ECONNRESET
web.1 2022-01-17 17:13:50.007 error Error: read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
web.1 2022-01-17 17:13:50.007 error uncaught exception: read ECONNRESET
`

My configuration and versions are as follows:
image
image
I recently updated the web adapter from the stabel to the latest available, hoping to fix the problem. Unfortunately, there was no improvement at all.
image
image
image
image
image

Please add your adapter to ioBroker.discovery

I am an automatic service from ioBroker that searches adapters and makes suggestions.

I noticed that your adapter is not integrated in the ioBroker.discovery. Using the Discovery adapter, ioBroker can automatically find devices or suggest services to the user for installation. If possible I would live to see your adapter added there.

Some adapters have already been added and you can use them as blueprints. See: https://github.com/ioBroker/ioBroker.discovery You need to fork this project and then create a PR for your adapter to be added.

Basically the plugins can do HTTP calls, UDP discovery, MDNS, UPNP and will iterate over all devices found by IP scan and check local serial ports. If you want you can also add new discovery methods but please try to do that with at least dependencies as possible.

Then create one file under lib/adapters for your adapter to implement the detection and proposal of an instance to the user.

On questions, the other developers will support in the forum or via GitHub issues too.

If no detection is possible, simply close this issue and I won't bother you again. ;-)

Thanks,
your automatic adapter checker.

Proxy 1.3.0 oder socket.io Problem?

Nach dem Update auf den Proxy Adapter V 1.3.0 kam es zu den unten gezeigten Fehlermeldungen. Verbindungen zu externen Kameras (motioneye) via iframe, funktionierten aus Google Chrome heraus nicht mehr. Die VIS ist dann komplett eingefroren. Generell war das gesamte System extrem träge.

Nach einem Rollback auf 1.2.1 war wieder alles normal. Proxy oder socket.io Problem?

`

web.0 12100 2022-06-02 08:06:55.939 info Connect extension "proxy/lib/proxy.js"
web.0 12100 2022-06-02 08:06:55.937 info {"target":"http://localhost:1880","ws":true,"secure":false,"changeOrigin":false,"proxyTimeout":10000,"xfwd":true,"pathRewrite":{"^/proxy.0/node-red/":"/"}}
web.0 12100 2022-06-02 08:06:55.936 info Install extension on /proxy.0/node-red/
web.0 12100 2022-06-02 08:06:55.935 info {"target":"http://localhost:8084","ws":true,"secure":false,"changeOrigin":false,"proxyTimeout":10000,"xfwd":true,"pathRewrite":{"^/proxy.0/api/":"/"}}
web.0 12100 2022-06-02 08:06:55.934 info Install extension on /proxy.0/api/
web.0 12100 2022-06-02 08:06:55.932 info {"target":"http://localhost:8083","ws":true,"secure":false,"changeOrigin":false,"proxyTimeout":10000,"xfwd":true,"pathRewrite":{"^/proxy.0/sonos/":"/"}}
web.0 12100 2022-06-02 08:06:55.931 info Install extension on /proxy.0/sonos/
web.0 12100 2022-06-02 08:06:55.918 info {"target":"http://localhost:8080","ws":true,"secure":false,"changeOrigin":false,"proxyTimeout":10000,"xfwd":true,"pathRewrite":{"^/proxy.0/motioneyeos/":"/"}}
web.0 12100 2022-06-02 08:06:55.828 info Install extension on /proxy.0/motioneyeos/
web.0 12100 2022-06-02 08:06:55.823 info socket.io server listening on port 8082
web.0 12100 2022-06-02 08:06:55.330 info starting. Version 5.2.0 in C:/iobroker/GLT/node_modules/iobroker.web, node: v14.16.0, js-controller: 4.0.23
`

`

web.0 8820 2022-06-02 07:52:34.175 error [proxy] Proxy error "http://localhost:1880": Error: connect ECONNREFUSED 127.0.0.1:1880
web.0 8820 2022-06-02 07:52:34.173 error Request GET "/socket.io/?key=nokey&EIO=3&transport=websocket&sid=CEoNeB_-DWfshazQAAAb" not found in requests
web.0 8820 2022-06-02 07:52:34.172 error [proxy] Cannot response
web.0 8820 2022-06-02 07:52:34.172 error [proxy] Proxy error "http://localhost:8083": Error: connect ECONNREFUSED 127.0.0.1:8083
web.0 8820 2022-06-02 07:52:34.170 error Request GET "/socket.io/?key=nokey&EIO=3&transport=websocket&sid=CEoNeB_-DWfshazQAAAb" not found in requests
web.0 8820 2022-06-02 07:52:34.170 error [proxy] Cannot response
`

Please check ioBroker.proxy with js-controller 2.0

Hi,

the new js-controller 2.0 will come into latest repository in the next days and we want to make sure that all adapters are working well. We already did a 2 weeks Beta test and so some adapter were aleady checked and some needed slight adjustments.

You can find more information in ioBroker/ioBroker.js-controller#482 and in the ioBroker Forum. If you have more technical questions please write in the referenced issue or in the Developer thread please. General questions are best in the genral thread.

Please update your systems to js-controller 2.0 and check your adapter.

Please close this issue once you have checked your adapter or received successfull reports from users.

Thank you very much for your support. Please contact us in the other Threads or Forum on any question.

Root-Verzeichnis?

Moin,

ich habe mal eine Verständnisfrage: in welches Verzeichnis (Root) werden denn die "Kontexte" (sprich web-Verzeichnisse) generiert? Werden diese generiert, müssen / dürfen die auf dem Host selbst angelegt werden? Ich sehe hier nichts, was generiert wird, wenn ich die Verzeichnisse als root anlege, klappt der Zugriff über den angegebenen Pfad via http auch nicht.

Ich hätte vermutet, dass wenn ich einen Ordner "Bilder" auf dem Host unter "opt/iobroker/proxy.0/" habe, ich diesen via http-request erreichen kann und wenn ich den Port im Kontext /Bilder unter http://localhost:8077 angegeben habe, das Bild sehe.

Bildchen auf Host: opt/iobroker/proxy.0/Bilder/Bild.jpg
HTTP-Repuest: http://192.168.178.45:8077/bild.jpg
...Varianten mit Verzeichnissen, gehen auch nicht

Danke
Ole

[proxy] too many parallel requests!

Hello!

Since one of the last updates i can't get my cameras to work.
After restart it works for some minutes but then it stops.
If i open the proxy url in browser, it tells:
[proxy] too many parallel requests!

How can i get rid of this message?

Thank you in advance,
Juergen

Think about to fix the issues found by adapter checker

I am an automatic service that looks for possible errors in ioBroker and creates an issue for it. The link below leads directly to the test:

https://adapter-check.iobroker.in/?q=https://raw.githubusercontent.com/ioBroker/ioBroker.proxy

  • [E104] No common.titleLang found in io-package.json
  • [E150] No common.connectionType found in io-package.json
  • [E152] No common.dataSource found in io-package.json
  • [E124] Main file not found under URL: https://raw.githubusercontent.com/ioBroker/ioBroker.proxy/master/main.js
  • [E504] "main.js found in package.json, but not found as file
  • [E605] No actual year found in copyright. Please add "Copyright (c) 2017-2022 bluefox [email protected]" at the end of README.md
  • [E701] No actual year found in LICENSE. Please add "Copyright (c) 2017-2022 bluefox [email protected]" at the start of LICENSE

I have also found warnings that may be fixed if possible.

  • [W113] Adapter should support compact mode

Thanks,
your automatic adapter checker.

File not found

I configured proxying of a local file

image

like that

image

but I get

image

[proxy] File "/volume1/public/loader.gif/" not found.

there is a trailing /
Could this be the problem?

timeout error

grafik

web is https
my grafana works with http

other error is here
grafik
with simple image

can not connect file to proxy.0

I want the MP3 file
/opt/iobroker/node_modules/iobroker.sayit/say.mp3
via the proxy adapter. So far without success.

Context:
say.mp3

URL:
/node_modules/iobroker.sayit/say.mp3

time out:
1000

Where is my mistake? Who can help me here.

Compatibility check to js-controller 4.0

Dear Adapter developer,

with js-controller 4.0 object definitions are now also checked that min/max in only provided for number/mixed objects and that the type of the default value matches to the object type.

If something is not correct this is logged as 'warning' or 'info' log.

Please also make sure to update to the lastest @iobroker/testing dependency 2.5.4 or to accept the PR from Apollon77 for legacy testing!

Please spent some time to verify your adapter by ideally starting with a fresh instance and do some actions and verify the log. If you see a warn or info log there from these checks please adjust the adapter and fix the relevant cases.

For questions please refer to ioBroker/ioBroker.js-controller#1749

Please close the issue after you checked it.

Thank you very much for your support to get the best experience for the growing numbers of ioBroker users!

Release script: Action required

Hi, it looks like you are using @alcalzone/release-script to manage your releases.
When updating to the latest version, you need to remove the following line from your .github/workflows/test-and-release.yml if you want the releases to keep working:

  deploy:
    # Trigger this step only when a commit on master is tagged with a version number
    if: |
      contains(github.event.head_commit.message, '[skip ci]') == false &&
      github.event_name == 'push' &&
-     github.event.base_ref == 'refs/heads/master' &&
      startsWith(github.ref, 'refs/tags/v')

It may also look like this one:

  deploy:
    # Trigger this step only when a commit on master is tagged with a version number
    if: |
      contains(github.event.head_commit.message, '[skip ci]') == false &&
      github.event_name == 'push' &&
-     github.event.base_ref == 'refs/heads/main' &&
      startsWith(github.ref, 'refs/tags/v')

Think about to fix the issues found by adapter checker

I am an automatic service that looks for possible errors in ioBroker and creates an issue for it. The link below leads directly to the test:

https://adapter-check.iobroker.in/?q=https://raw.githubusercontent.com/ioBroker/ioBroker.proxy

  • [E150] No common.connectionType found in io-package.json
  • [E152] No common.dataSource found in io-package.json
  • [E124] Main file not found under URL: https://raw.githubusercontent.com/ioBroker/ioBroker.proxy/master/main.js
  • [E504] "main.js found in package.json, but not found as file
  • [E605] No actual year found in copyright. Please add "Copyright (c) 2017-2021 bluefox [email protected]" at the end of README.md
  • [E701] No actual year found in LICENSE. Please add "Copyright (c) 2017-2021 bluefox [email protected]" at the start of LICENSE

I have also found warnings that may be fixed if possible.

  • [W113] Adapter should support compact mode

Thanks,
your automatic adapter checker.

proxy 1.2 cannot use local files. TypeError: mime.lookup is not a function

If I try to serve files I get always below error:
TypeError: mime.lookup is not a function at that.app.use (/opt/iobroker/node_modules/iobroker.proxy/lib/proxy.js:229:46) at Layer.handle [as handle_request] (/opt/iobroker/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/opt/iobroker/node_modules/express/lib/router/index.js:317:13) at /opt/iobroker/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/opt/iobroker/node_modules/express/lib/router/index.js:335:12) at next (/opt/iobroker/node_modules/express/lib/router/index.js:275:10) at expressInit (/opt/iobroker/node_modules/express/lib/middleware/init.js:40:5) at Layer.handle [as handle_request] (/opt/iobroker/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/opt/iobroker/node_modules/express/lib/router/index.js:317:13) at /opt/iobroker/node_modules/express/lib/router/index.js:284:7

This happens with any file, example if you install in proxy a context test/ and the path is /opt/iobroker/iobroker-data/files/web for example.

There is a second error: you get files listed if you use above example. On this level you can click on the files and if they are files 1st error shows up, if they are folders, like admin, like lib the folder opens but you cannot click then on any item there because the the server does not add the lib/ subdir in the file link, so all files just have ./ in front, even if they are in a sub directory of the proxy folder!

Sorry, running Node V 10.19 and iobroker.web 3.0.2 but have the same problem on my production system running Proxy 1.1.1 and web 2.4.6

too many parallel requests: Allow configuration

Hi,
my webapp uses web adapter with proxy adapter and throws often errors like:

web.0
	2022-05-20 14:41:11.139	warn	[proxy] too many parallel requests for "/css/CascadiaMono.woff2"
web.0
	2022-05-20 14:40:17.112	info	https server listening on port 8082
web.0
	2022-05-20 14:40:17.105	info	Connect extension "proxy/lib/proxy.js"
web.0
	2022-05-20 14:40:17.100	info	{"target":"http://192.168.0.20/wh/","ws":true,"secure":false,"changeOrigin":false,"proxyTimeout":10000,"xfwd":true,"pathRewrite":{"^/wh/":"/"}}
web.0
	2022-05-20 14:40:17.071	info	Install extension on /wh/
web.0
	2022-05-20 14:40:16.879	info	starting. Version 4.3.0 in /opt/iobroker/node_modules/iobroker.web, node: v14.19.2, js-controller: 4.0.23

Could you please increase the amount of parallel requests through the proxy?

Pfade zu Dateien funktionieren nicht

Hallo,

ich habe das Problem, dass Pfade die auf Dateien zeigen nicht funktionieren.

Es kommt der Fehler:
[proxy] File "/opt/iobroker/download/bild.jpg/" not found.

Eingestellt habe ich alles laut readme.
Wenn ich auf einen Ordner verweise klappt es.
Wenn man dort allerdings auf eine Datei klickt kommt der selbe Fehler.

Hier habe ich es schonmal im ioBroker Forum angesprochen.

Compatibility check and testing for Node.js 14 and 16

Dear Adapter develop,

Node.js 14 is now available for a year and Node.js 16 was release just some days ago and will become LTS by October 2021. We plan to update the ioBroker Node.js recommendation (currently 12.x) to 14.x later this year.

Please check your adapter with Node.js 14 especially, and ideally also directly with Node.js 16

Please add both versions to the adapter testing which is executed on commits.

If your adapter requires a certain minimum version of Node.js please set the 'engine' setting in package.json accordingly! Please also do this if the adapter is not able to work in certain Node.js versions, so that ioBroker can prevent users from installing te adapter if not compatible!

On questions please talk to us at ioBroker/ioBroker.js-controller#1138

Please close the issue after you checked it.

Thank you very much for your support!

Invalid handling of mimeTypes

I have created a proxy mapping to a local folder. Within this folder exists a file i18n.properties. When I try to access this file I get an exception in line 229 of proxy.js. Requests to other files, eg. index.html, work fine.

I could fix the problem with a surrounding try/catch for mime.getType(fileExt);

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.