From 3dd75f500ac172d60d1b44015f023ba740ef4179 Mon Sep 17 00:00:00 2001 From: Robert Gingras Date: Wed, 15 Apr 2026 12:12:06 -0400 Subject: [PATCH] Serve docs statically via nginx instead of proxying to opensource-docs service Replace the proxy_pass to localhost:2998 in the bare-domain nginx server block with a root + try_files directive serving static files from the Docusaurus build directory. - nginx-conf.ejs: static file serving from /opt/opensource-server/mie-opensource-landing/build - Makefile: remove systemd service install/enable/start from install-docs - Delete mie-opensource-landing/systemd/opensource-docs.service - Dockerfile: install nginx, serve on port 80, add standalone site config - New images/docs/docs-site.conf for the test container Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Makefile | 4 --- create-a-container/views/nginx-conf.ejs | 31 +++---------------- images/docs/Dockerfile | 9 ++++-- images/docs/docs-site.conf | 16 ++++++++++ .../systemd/opensource-docs.service | 18 ----------- 5 files changed, 26 insertions(+), 52 deletions(-) create mode 100644 images/docs/docs-site.conf delete mode 100644 mie-opensource-landing/systemd/opensource-docs.service diff --git a/Makefile b/Makefile index be8b61e2..5d0db07b 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,3 @@ install-pull-config: install-docs: cd mie-opensource-landing && npm install --production cd mie-opensource-landing && npm run build - install -m644 -oroot -groot mie-opensource-landing/systemd/opensource-docs.service /etc/systemd/system/opensource-docs.service - systemctl daemon-reload || true - systemctl enable opensource-docs.service - systemctl start opensource-docs.service || true diff --git a/create-a-container/views/nginx-conf.ejs b/create-a-container/views/nginx-conf.ejs index 2dcb26b6..35fcb3a8 100644 --- a/create-a-container/views/nginx-conf.ejs +++ b/create-a-container/views/nginx-conf.ejs @@ -435,34 +435,11 @@ http { proxy_pass http://error_pages; } - # Proxy to documentation site + # Serve documentation site statically location / { - proxy_pass http://localhost:2998; - proxy_http_version 1.1; - - # Proxy headers - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Host $host; - proxy_set_header X-Forwarded-Port $server_port; - - # WebSocket support - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - - # Timeouts - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 60s; - - # Buffering (disable for SSE/streaming) - proxy_buffering off; - proxy_request_buffering off; - - # Allow large uploads - client_max_body_size 2G; + root /opt/opensource-server/mie-opensource-landing/build; + index index.html; + try_files $uri $uri/ $uri.html /404.html =404; } } <%_ }) _%> diff --git a/images/docs/Dockerfile b/images/docs/Dockerfile index 017b84ce..4d5575b5 100644 --- a/images/docs/Dockerfile +++ b/images/docs/Dockerfile @@ -1,12 +1,15 @@ FROM nodejs RUN apt-get update && \ - apt-get install -y make && \ + apt-get install -y make nginx && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* COPY . /opt/opensource-server RUN cd /opt/opensource-server && make install-docs -EXPOSE 2998 -LABEL org.mieweb.opensource-server.services.http.default-port=2998 +# Replace the default nginx site with our docs config +COPY ./images/docs/docs-site.conf /etc/nginx/sites-enabled/default + +EXPOSE 80 +LABEL org.mieweb.opensource-server.services.http.default-port=80 diff --git a/images/docs/docs-site.conf b/images/docs/docs-site.conf new file mode 100644 index 00000000..5948b3d7 --- /dev/null +++ b/images/docs/docs-site.conf @@ -0,0 +1,16 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + root /opt/opensource-server/mie-opensource-landing/build; + index index.html; + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + location / { + try_files $uri $uri/ $uri.html /404.html =404; + } +} diff --git a/mie-opensource-landing/systemd/opensource-docs.service b/mie-opensource-landing/systemd/opensource-docs.service deleted file mode 100644 index 8d470165..00000000 --- a/mie-opensource-landing/systemd/opensource-docs.service +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Description=Opensource Documentation Server -After=network.target environment.service - -[Service] -Type=simple -User=root -WorkingDirectory=/opt/opensource-server/mie-opensource-landing -EnvironmentFile=/etc/environment -ExecStart=/usr/bin/npm run serve -Restart=on-failure -RestartSec=10s - -# Environment -Environment=NODE_ENV=production - -[Install] -WantedBy=multi-user.target