-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy path_config_docker.yml
More file actions
58 lines (56 loc) · 2.7 KB
/
_config_docker.yml
File metadata and controls
58 lines (56 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# _config_docker.yml
#
# This configuration file contains overrides specifically for running the
# Jekyll site within a local Docker container. It solves a critical issue where
# modern browsers block URLs containing '0.0.0.0'.
#
# This file is loaded *after* the main `_config.yml` by using the command:
# `jekyll serve --config _config.yml,_config_docker.yml`
# ------------------------------------------------------------------------------
# Part 1: Make the Server Accessible from Outside the Container
# ------------------------------------------------------------------------------
#
# A Docker container has its own isolated network. By default, a web server
# inside a container might only listen on its internal 'localhost' (127.0.0.1),
# which is inaccessible from your main computer (the host).
#
# Setting `host: 0.0.0.0` tells the Jekyll server to listen on ALL available
# network interfaces inside the container. This makes it possible for Docker's
# port mapping (e.g., `-p 4000:4000`) to forward traffic from your computer's
# localhost to the Jekyll server running inside the container.
#
# ---
# CRITICAL NOTE ON WHY THIS MUST BE IN A FILE: The `jekyll serve` command has a
# `--host` flag which seems like an easier option. However, that flag has the
# highest precedence and will OVERRIDE ALL related settings from ANY config
# file.
#
# If you run `jekyll serve --host 0.0.0.0`, it forces Jekyll to set `site.url`
# to 'http://0.0.0.0:4000', ignoring any `url` value you set. Therefore, to
# control the `host` and `url` settings independently, the configuration *must*
# be done through a file and the `--host` flag *must not* be used.
# ---
#
host: 0.0.0.0
# ------------------------------------------------------------------------------
# Part 2: Fix the Browser-Blocking URL Issue
# ------------------------------------------------------------------------------
#
# THE PROBLEM: As noted above, setting the host to '0.0.0.0' causes Jekyll's
# default behavior to set the site's URL to 'http://0.0.0.0:4000'. Modern
# browsers like Firefox have a security feature that blocks any requests made
# to this URL, rendering the local development site completely broken.
#
# THE SOLUTION: We must override Jekyll's URL generation. By setting `url: ""`,
# we instruct Jekyll NOT to prepend any hostname to its generated links.
#
# Instead of creating an *absolute* URL like 'http://0.0.0.0:4000/about/',
# Jekyll will now generate a *root-relative* URL like '/about/'.
#
# The browser, which is already viewing the site at 'http://localhost:4000',
# sees the relative link '/about/' and correctly requests the page from
# 'http://localhost:40.0.0/about/'.
#
# This completely avoids the '0.0.0.0' string in the HTML, solving the issue.
#
url: ""