mockko / livereload

LiveReload applies CSS/JS changes to Safari or Chrome w/o reloading the page (and autoreloads the page when HTML changes)
http://livereload.com/
1.18k stars 56 forks source link

LiveReload and remote server #45

Closed NV closed 13 years ago

NV commented 13 years ago

I do most of my day job on remote server via ssh. I want to use livereload there as well as on my local machine.

We need

  1. UI to define host other than localhost (not a big deal)
  2. instructions for apache, nginx and lighthttpd to forward livereload's port (35729) to the WebSockets default. Need some help here.
NV commented 13 years ago

Forward port via ssh:

ssh -L35729:localhost:35729 my_remote_server

Don't need any modification in LR.

man ssh:

-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the con- nection is forwarded over the secure channel, and a connection is made to host port hostport from the remote machine. Port forwardings can also be specified in the configuration file. IPv6 addresses can be specified with an alternative syntax: [bind_address/]port/host/hostport or by enclosing the address in square brackets. Only the superuser can forward privileged ports. By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection to a specific address. The bind_address of "localhost'' indicates that the listening port be bound for local use only, while an empty address or '*' indicates that the port should be avail- able from all interfaces.

NV commented 13 years ago

Would be great to have a shortcut like

➤ livereload --remote my_remote_server:~/example.com/www

It should:

  1. run ssh -L35729:localhost:35729 my_remote_server locally (that's easy)
  2. run livereload ~/example.com/www on the remote server (is it even possible?)
NV commented 13 years ago

Turns out it's simple as

ssh -L35729:localhost:35729 my_remote_server 'livereload ~/example.com/www'
justmoon commented 13 years ago

The correct solution is to provide a way to configure the server address. SSH tunnels are not sufficient as a workaround since they take extra work to setup, maintain on reboot etc. When your Chrome is on Windows, it's even more complicated to set up.

Just make host and port configurable, just like every other networked application in the world.

justmoon commented 13 years ago

Wrote a patch that makes host and port configurable in Safari and Chrome:

https://github.com/justmoon/livereload/commit/6dcca4d55043d72f776d8697f3df459a335acb60

NV commented 13 years ago

Thanks for the patch! I'm looking into it.

NV commented 13 years ago

Landed in 00ff8a05e1a748c895b55f7da59e4e0cc2803186. I've made a quick testing and haven't found any problems with it.