-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Websocket for LiveReload using wrong port if Hugo binds to port 80 #2205
Comments
|
I like typing less stuff in my url bar? "Because."? Does it matter? Why shouldn't I use port 80? There's a config option for it and in certain situations it causes other functionality to fail. The port I choose for In analogy/joke form:
Not helpful, doc. |
If you could provide a reason other than convenience, the issue might get higher priority, that's all. |
This piqued my interest, and I decided to try it with Hugo v0.16 (hugo_0.16-1_armhf.deb) running on my Raspberry Pi 3:
(I set my home router resolves
So that answered two questions that I was going to ask @chuyskywalker:
I then ran That said, I don't think Hugo ever sets LiveReload to listen at 35729 by default. When
So, my suspicion would be on the client-side livereload.js. But let's google first, and lo and behold!
So, it is Google Chrome and Mozilla Firefox's doing. And it is probably relatively recent too, which explains why it used to work for you, but no longer. Since it is not Hugo's bug, we can choose to:
Probably not too high priority. Any volunteers? 😉 |
Actually, based on one of your links, livereload can be told what port to use, ala
Seems like it would be sane to inject that into the URL based on the port that Hugo is bound to |
I have exactly zero go experience, so this is a WILD shot in the dark, and probably wrong in so very many ways, but... |
@chuyskywalker Good catch! I missed or misunderstood that, and glad that you came up with a fix! It looks good to me at first glance, though I haven't tested it yet. Care to make a pull request so more experienced Hugo developers can look at it and eventually merge it? See our https://github.com/spf13/hugo/blob/master/CONTRIBUTING.md guide. Many thanks! |
Actually, my code fails. I'm not a |
@dplesca -- I copied https://github.com/dplesca/hugo/commit/8323f694d54a3605a234e5572138025c4ad72491 into my own repo, compiled, and tried it. Tests pass and live reload works on port 80 afterwards, yay! |
If hugo is run with port 80 or 443, live reload does not correctly bind to the same port, instead using port 35729. This commit adds functionality to inform livereload of the correct port to bind to. Fixes gohugoio#2205
Thank you @chuyskywalker and @dplesca for your contribution! |
If hugo server is run on port 80 or 443, LiveReload does not correctly bind to the same port, instead using port 35729. This commit adds functionality to inform LiveReload of the correct port to bind to. See livereload/livereload-js#16 Partially contributed by Jeff Minard (@chuyskywalker). Fixes gohugoio#2205
Binding LiveReload to the same port Hugo is run from breaks the ability to use a reverse proxy. Ideally, the port we pass to the LiveReload script should be the port that the page is loaded from, not the port that Hugo is run from. Problem:
Proposed solution:Write the port dynamically on the client:
Thoughts? |
@aral I am almost in the same situation as yours. I use Nginx as reverse proxy for Hugo (among others). So, if you or anyone else uses Nginx, this solution works for me with the command
I hope that helps someone using Nginx as reverse proxy. |
@pothi Thanks for this. I didn’t know there was a --liveReloadPort option so I’d added a hack to my proxy server to rewrite the URLs for Hugo. I can now remove the hack. Much appreciated :) |
Just leaving a comment here that I also encountered this issue when using Hugo in combination with HAProxy as a reverse proxy for TLS termination. I saw errors in the console of Google Chrome that the livereload.js file couldn't be reached. I added |
Let's say I clone this repo:
Then start up a docker container on Hugo 0.16:
Where I have watch on and I'm listening on port 80. When you load the site, you get:
Which is clearly trying to connect to the hugo server on the wrong port. If you pop the port number up one value:
It works as expected (from chrome console):
Originally discussed and discovered here: https://discuss.gohugo.io/t/live-reload-unconnectable-in-docker-container/3457/4
The text was updated successfully, but these errors were encountered: