Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Allow different configuration and serving ports (to allow for nginx + ssl) #48

Open
dlikhten opened this issue Nov 7, 2013 · 6 comments

Comments

@dlikhten
Copy link

dlikhten commented Nov 7, 2013

So I want to run SSL in development. This poses a challenge because an SSL-enabled page will not accept non-ssl javascript.

So naturally rack-livereload needs to run in ssl mode. But of course I don't expect you guys to write an SSL server. So NGINX to the rescue!!!

If you were to let me specify a port, say 1234, but the server runs on a different port, say 4567, I can have my nginx redirect port 1234 (in ssl) to talk to non-ssl port 4567. And thus I can have ssl in my development environment and still get live reloading.

@johnbintz
Copy link
Owner

So the issue is that you're loading pages on localhost:4567, but because of the proxying, localhost:1234 is being used for urls to the LiveReload JS? Try setting the :host option in the middleware configuration to localhost:4567 to override the automatic detection. Since using this through a proxy is such an edge case, I'll only add code to detect and use that if someone else provides it, but I think hard-coding :host will do it for now.

@dlikhten
Copy link
Author

dlikhten commented Nov 7, 2013

@johnbintz so if I can get my websockets to listen on port [default] but then the js get rendered/requests sent to my overridden port, then this solves the problem as it becomes just an nginx config issue.

@johnbintz
Copy link
Owner

Does WebSockets need to go through SSL too for this to work? I have very little experience with SSL interactions, beyond setting up with Apache to serve using it.

@dlikhten
Copy link
Author

dlikhten commented Nov 7, 2013

Once you are on a ssl-enabled page, the browser is VERY unhappy with insecure content. It will refuse to communicate via ajax to non-ssl enabled endpoints. Not 100% sure about websockets but I believe it is subject to the same restrictions.

So point is all I need is the enabling functionality (ability to poke one port, but serve on another port). I think this can be overridden in the page by overriding that global constant that rack injects, so the JS thinks one port is being used, and nginx can do all the ssl work for you, meanwhile the server is being really ignorant of all this and just listening for non-ssl.

@johnbintz
Copy link
Owner

Then, if I understand correctly, I would try changing both :host and :live_reload_port to the host:port nginx is serving from and the port through which nginx will proxy WebSockets to an SSL version, respectively. I can try setting up a similar setup tomorrow if that doesn't work and play with it myself to figure it out.

@mattscilipoti
Copy link

Any word on this? I'm having similar issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants