wiki_ghostguild/nginx.conf
Jennie Robinson Faber 6200c4cd2a Add nginx proxy for OG meta tags and CSS injection
Traefik was routing directly to Outline, so the nginx.conf
was unused. Add nginx as an intermediary service to enable
sub_filter injection of OG tags on the homepage and custom
CSS on all pages.
2026-03-02 11:16:26 +00:00

104 lines
3.6 KiB
Nginx Configuration File

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 100M;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript
application/javascript application/json
application/xml+rss image/svg+xml;
upstream outline {
server outline:3000;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name wiki.ghostguild.org;
# Serve custom theme files
location /custom/ {
alias /opt/ghost-guild-wiki-theme/;
expires 1h;
add_header Cache-Control "public";
}
# Health check
location = /api/health {
proxy_pass http://outline;
access_log off;
}
# Homepage: inject OG meta tags + CSS
location = / {
proxy_pass http://outline;
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 Accept-Encoding "";
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# OG tags after <head> so they appear before Outline's own tags
sub_filter '<head>' '<head><meta property="og:title" content="Ghost Guild Wiki" /><meta property="og:description" content="A living knowledge base for Baby Ghosts &amp; Ghost Guild." /><meta property="og:type" content="website" /><meta property="og:url" content="https://wiki.ghostguild.org" /><meta name="twitter:card" content="summary" /><meta name="twitter:title" content="Ghost Guild Wiki" /><meta name="twitter:description" content="A living knowledge base for Baby Ghosts &amp; Ghost Guild." />';
# CSS injection (must redeclare; sub_filter doesn't inherit across location blocks)
sub_filter '</head>' '<link rel="stylesheet" href="/custom/ghost-guild.css" /></head>';
sub_filter_once on;
sub_filter_types text/html;
}
# Reverse proxy to Outline with CSS injection
location / {
proxy_pass http://outline;
# Standard 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;
# Disable encoding so sub_filter can process the response
proxy_set_header Accept-Encoding "";
# WebSocket support (required for real-time collaboration)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Inject custom CSS before </head>
sub_filter '</head>' '<link rel="stylesheet" href="/custom/ghost-guild.css" /></head>';
sub_filter_once on;
sub_filter_types text/html;
}
}
}