|
1 | | -# Map Accept headers to Markdown flag |
2 | | -map $http_accept $wants_markdown { |
3 | | - default 0; |
4 | | - "~*text/markdown" 1; |
5 | | - "~*text/plain" 1; |
6 | | -} |
7 | | - |
8 | | -# Define named upstream for local dev |
9 | | -upstream local_docs { |
10 | | - server 127.0.0.1:3000; |
11 | | -} |
12 | | - |
13 | | -# Map host to upstream |
14 | | -map $host $docs_upstream { |
15 | | - "docs.apify.com" https://apify.github.io/apify-docs; # production |
16 | | - default http://local_docs; # local dev |
17 | | -} |
18 | | - |
19 | 1 | server { |
20 | 2 | listen 0.0.0.0:8080; |
21 | | - server_name docs.apify.loc docs.apify.com; |
| 3 | + server_name docs.apify.com; |
22 | 4 |
|
23 | | - # Homepage: llms.txt fallback |
24 | 5 | location = / { |
25 | | - if ($wants_markdown) { |
26 | | - rewrite ^ /__proxy/llms.txt last; |
27 | | - } |
28 | | - proxy_pass $docs_upstream; |
29 | | - proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/; |
30 | | - } |
31 | | - |
32 | | - # Direct llms.txt files |
33 | | - location = /llms.txt { |
34 | | - proxy_pass $docs_upstream/llms.txt; |
35 | | - proxy_hide_header Content-Type; |
36 | | - add_header Content-Type "text/markdown; charset=utf-8" always; |
37 | | - proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/; |
38 | | - } |
39 | | - |
40 | | - location = /llms-full.txt { |
41 | | - proxy_pass $docs_upstream/llms-full.txt; |
42 | | - proxy_hide_header Content-Type; |
43 | | - add_header Content-Type "text/markdown; charset=utf-8" always; |
44 | | - proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/; |
45 | | - } |
46 | | - |
47 | | - # Generic Markdown fallback for all URLs |
48 | | - location / { |
49 | | - if ($wants_markdown) { |
50 | | - # rewrite clean URLs or URLs ending in .md to internal proxy |
51 | | - rewrite ^(/.*\.md)$ /__proxy$1 last; # already .md |
52 | | - rewrite ^(/.*[^/.])$ /__proxy$1.md last; # no extension |
53 | | - } |
54 | | - proxy_pass $docs_upstream; |
55 | | - proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/; |
56 | | - } |
57 | | - |
58 | | - # Internal proxy for Markdown handling |
59 | | - location ^~ /__proxy/ { |
60 | | - internal; |
61 | | - rewrite ^/__proxy/(.*)$ /$1 break; |
62 | | - |
63 | | - proxy_pass $docs_upstream; |
64 | | - proxy_hide_header Content-Type; |
65 | | - add_header Content-Type "text/markdown; charset=utf-8" always; |
66 | | - |
67 | | - proxy_redirect https://apify.github.io/ https://apify.github.io/apify-docs/; |
| 6 | + proxy_pass https://apify.github.io/apify-docs/; |
68 | 7 | } |
69 | 8 |
|
70 | | - # proxies to other repositories |
| 9 | + # proxies to other repositories |
71 | 10 | location /api/client/js { |
72 | 11 | proxy_pass https://apify.github.io/apify-client-js/; |
73 | 12 | } |
|
0 commit comments