-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I'm figuring out how to run zola serve behind an nginx reverse proxy with live reload. There's a few things that need sorting out before this becomes practical.
(a) Currently zola serve --base-url https://example.com is adding a http:// prefix and port suffix so the base URL becomes a nonsensical http://https//example.com:1111/. I understand this makes sense in the context of a local development server, but I'm suggesting to completely remove this logic and keep the base URL as-is. This would make it consistent with the behavior of zola build --base-url and give users more flexibility.
(b) An option to set a fixed port for the livereload websocket would be helpful. I suggest --live-reload-port.
(c) In a typical reverse proxy setup both the site and the livereload websocket would be exposed to the internet on the same port (80 or 443). The port zola opens the websocket on (1024 or whatever) is different from the port the javascript needs to connect to from the outside (80 or 443). So I'm suggesting to add an additional --live-reload-port-external option that's merely controlling the port in the <script src="/livereload.js?port=1024&mindelay=10"></script> tag.
This all seems quite easy to do and I can open a PR if the changes are welcome.
Maybe if other people are interested in this setup I could add a section to the documentation explaining it. What do you think?
The nginx configuration is really simple.
server {
…
location / {
proxy_pass http://127.0.0.1:1111;
}
location = /livereload {
proxy_pass http://127.0.0.1:1024;
}
}