Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 3 additions & 64 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,73 +1,12 @@
# Map Accept headers to Markdown flag
map $http_accept $wants_markdown {
default 0;
"~*text/markdown" 1;
"~*text/plain" 1;
}

# Define named upstream for local dev
upstream local_docs {
server 127.0.0.1:3000;
}

# Map host to upstream
map $host $docs_upstream {
"docs.apify.com" https://apify.github.io/apify-docs; # production
default http://local_docs; # local dev
}

server {
listen 0.0.0.0:8080;
server_name docs.apify.loc docs.apify.com;
server_name docs.apify.com;

# Homepage: llms.txt fallback
location = / {
if ($wants_markdown) {
rewrite ^ /__proxy/llms.txt last;
}
proxy_pass $docs_upstream;
proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/;
}

# Direct llms.txt files
location = /llms.txt {
proxy_pass $docs_upstream/llms.txt;
proxy_hide_header Content-Type;
add_header Content-Type "text/markdown; charset=utf-8" always;
proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/;
}

location = /llms-full.txt {
proxy_pass $docs_upstream/llms-full.txt;
proxy_hide_header Content-Type;
add_header Content-Type "text/markdown; charset=utf-8" always;
proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/;
}

# Generic Markdown fallback for all URLs
location / {
if ($wants_markdown) {
# rewrite clean URLs or URLs ending in .md to internal proxy
rewrite ^(/.*\.md)$ /__proxy$1 last; # already .md
rewrite ^(/.*[^/.])$ /__proxy$1.md last; # no extension
}
proxy_pass $docs_upstream;
proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/;
}

# Internal proxy for Markdown handling
location ^~ /__proxy/ {
internal;
rewrite ^/__proxy/(.*)$ /$1 break;

proxy_pass $docs_upstream;
proxy_hide_header Content-Type;
add_header Content-Type "text/markdown; charset=utf-8" always;

proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/;
proxy_pass https://apify.github.io/apify-docs/;
}

# proxies to other repositories
# proxies to other repositories
location /api/client/js {
proxy_pass https://apify.github.io/apify-client-js/;
}
Expand Down
Loading