Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port forwarding over SSH (probably just a few modifications to common.js) #2681

Closed
belveder79 opened this issue Nov 3, 2023 · 10 comments
Closed
Labels
enhancement New feature or request

Comments

@belveder79
Copy link

The Feature

First kudos - it is amazing what you have created. I have two digit readers in action, and it works great!

I just discovered one issue that might or might not be corrected easily. One of the meters is on a remote site, which I can just access over ssh with some port forwarding to the ESP32. The access basically works, but since there is some hard-coded redirection to an IP, most of the page is not served. It can easily be reproduced.

ssh <routerip> -L4000:<espip>:80

There is a workaround on a Mac/Linux at least, where there is the virtual interface (say bridge1) which is given the same IP as the ESP and then port-map the ip/port from remote to local:

# activate first
sudo ifconfig bridge1 alias 10.97.1.233 up
# ssh and map
sudo ssh <routerip> -L10.97.1.233:80:10.97.1.233:80
...
# deactivate after
sudo ifconfig bridge1 -alias 10.97.1.233

In between accessing the IP (10.97.1.233 in this case) everything works.

@belveder79 belveder79 added the enhancement New feature or request label Nov 3, 2023
@caco3
Copy link
Collaborator

caco3 commented Nov 3, 2023

I think this is out of scope for this project as it is very special.
The device only has an interface for HTTP (Port 80) ans MQTT (Port 1883).
If i understand you right, you only have a tunnel to port 22 (SSH). So the device would need to serve HTTP on port 22 for you. This is very special. Not sure what kind of router7gateway you have, eg. with a fritzbox, you could route the external port 22 to the port 80 of the device. Your webbrowser then would need to access the device using port 22.

@belveder79
Copy link
Author

belveder79 commented Nov 3, 2023 via email

@belveder79
Copy link
Author

belveder79 commented Nov 3, 2023 via email

@caco3
Copy link
Collaborator

caco3 commented Nov 4, 2023

I think you might run into our test functions for the UI, see https://github.com/jomjol/AI-on-the-edge-device/blob/rolling/sd-card/html/common.js#L2..L17

Is your host name maybe empty/not properly transmitted?

@belveder79
Copy link
Author

belveder79 commented Nov 4, 2023 via email

@caco3
Copy link
Collaborator

caco3 commented Nov 4, 2023

Can you test if it is fixed when you simply remove this part?

|| (host == "")

@belveder79
Copy link
Author

indeed... it is actually this part

(host == "127.0.0.1") 

as a standard redirect goes to the loopback device. Just using the port forwarding to the local ethernet interface works...

@caco3
Copy link
Collaborator

caco3 commented Nov 4, 2023

Hmm, not sure why this goes wrong for you.
But is it working now?

@belveder79
Copy link
Author

belveder79 commented Nov 5, 2023

Well, if you redirect it to something like

-L80:10.97.1.233:80

you necessarily have to access it under

http://127.0.0.1:80

and then the test code kicks in.

It is working for me now, but the 127.0.0.1 should probably be removed if it is not ultimately necessary and for testing only. It would make the port forwarding work for everybody then - I did not think about running into such a problem at all when I started...

@caco3
Copy link
Collaborator

caco3 commented Nov 7, 2023

Reworked inhttps://github.com/jomjol/AI-on-the-edge-device/commit/36c12b400bfab15321e409c4421074e4223432a1

@caco3 caco3 closed this as completed Nov 7, 2023
Slider0007 added a commit to Slider0007/AI-on-the-edge-device that referenced this issue Dec 14, 2023
Avoid issues with forwarding to loopback 127.0.0.1
(jomjol#2681)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants