Reputation: 373
I would like to remotely work on (or develop) a React application, but still check the results in a local browser. Using npm
, on the remote server, I launch
npm start
in order to start the application.
It returns
Server running at http://localhost:1234
Then, locally, I can access to the application in my browser at the address machineIP:1234
where machineIP
is the IP address of the remote host. This looks convenient, but I do not want to expose my application to the entire world.
I am actually very surprised that the port 1234 is suddenly open to anyone. Maybe this is a configuration of my remote server under Ubuntu 19.04.
I see two potential directions:
How would you proceed to privately check your application (in your local browser) while it is running (and being constantly restarted) on a remote server?
Upvotes: 4
Views: 3286
Reputation: 179
I work a lot with node and react and I a tool to solve this problem for me. it is self-hosted and free, it use ssh but helps you with a UI
https://github.com/vicjicaman/tunnel-tool
If you need any help let me know!
Upvotes: 1
Reputation: 360
Firstly, you may want to check if there is a firewall running on that remote server. If there isn't, then ufw
is probably a good option. Make sure to sudo ufw allow 22/tcp
or sudo ufw allow OpenSSH
before sudo ufw enable
so you can still SSH into the server. You can also choose to allow connections to port 1234 from your own local IP using sudo ufw allow from localIP to any port 1234
, where localIP
is the public IP address of your local machine. Then you can simply go to machineIP:1234
in your browser to view your application.
If you don't want to or can't open port 1234 to your own IP, but do still have SSH access, then you can also set up an SSH tunnel using ssh -L 1234:machineIP:1234 machineIP
. Then you can view your application by going to localhost:1234
in your browser.
Upvotes: 3