[solved] Links pointing to localhost instead base_url

Hi,

I have problems getting Zola to wok on my setup. On my public server I have two VMs. One VM is running nginx as a reverse proxy, the other VM is running Zola. When running zola serve -i 0.0.0.0 the website is accessable under https://some-url.com but all links are pointing to 127.0.0.1, i.e. 127.0.0.1/archive. The theme I used on this installation is also not applied, I just get a plain site with text. But I guess this is related to the “localhost-problem”.
When I start Zola with zola serve -i 0.0.0.0 -u some-url.com the website won’t load at all.

What I’m doing wrong?

Here is my config.toml:

# Be sure to change these!
base_url = "https://some-url.com"

menu_items = [
    # each of these is optional, name and url are required
    # $BASE_URL is going to be substituted by base_url from configuration
    {name = "blog", url = "$BASE_URL"},

    # tags should only be enabled if you have "tags" taxonomy
    # see documentation below for more details
    {name = "tags", url = "$BASE_URL/tags"},
    {name = "archive", url = "$BASE_URL/archive"},
]

And here is the config of my reverse proxy:

server {
    listen 80;
    listen [::]:80;
    server_name some-url.com;

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    location / {
        proxy_pass http://some-url.com:1111;
    }

    server_name some-url.com;
    ssl_certificate /etc/letsencrypt/live/some-url.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/some-url.com/privkey.pem;
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;  # about 40000 sessions
    ssl_session_tickets off;

    # curl https://ssl-config.mozilla.org/ffdhe2048.txt > /path/to/dhparam
#    ssl_dhparam /path/to/dhparam;

    # intermediate configuration
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
    ssl_prefer_server_ciphers off;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000" always;
}

Okay, after some more research I have now found out that ‘zola serve’ is actually only for testing and I have to use ‘zola build’ to build the website.

I have two config files, one for dev and one for production/release

config

# The URL the site will be built for
base_url = "http://127.0.0.1:1111"

config.production

# The URL the site will be built for
base_url = "https://mydomain.com"

Then use a makefile with the following


ZOLA = /opt/local/bin/zola
CONFIG_DEV = config.toml
CONFIG_PROD = config-production.toml

build:
	$(ZOLA) build

build-prod:
	$(ZOLA) --config $(CONFIG_PROD) build

Then finally push (rsync in this case) to a remote machine.

rsync:
	$(RSYNC) -av -e "ssh -i \"$(SSH_CERT_PATH)\"" $(OUTPUT_PATH) $(USER)@$(HOST):$(DEST_PATH)