This repository was archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathserver.conf
49 lines (44 loc) · 1.69 KB
/
server.conf
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
root /usr/share/nginx/html/new-docs/;
# FYI: Redirect breaks
location = / {
# `$scheme://$http_host` is because otherwise, it adds the port nginx is
# listening on. Since we listen on 80 but expose 8000 by default from docker
# locally, the redirect was going to `localhost/docs` which doesn't have a
# server listening.
return 302 $scheme://$http_host/docs;
}
location / {
try_files /public/$uri /public/$uri/index.html /static/$uri =404;
}
# explicit 301 redirects
location = /software/known-issues.html {
return 301 https://github.com/stellar/go/issues;
}
# .+ (vs .*) is important to avoid a redirect loop when rewriting all
# non-crawler requests to `/api/`
location ~* ^/api/(?<path>.+)$ {
set $noJs false;
set $needsCrawlerRedirect '';
if ($arg_javascript = 'false') {
set $noJs true;
}
if ($noJs = true) {
rewrite ^/api/(.*) /no-js/api/$1;
}
if ($noJs = false) {
rewrite ^/api/.*$ /api/;
}
# SEO optimization for API Reference. This lets crawlers only see the content
# from each individual section.
# UA check sourced from https://gist.github.com/thoop/8165802
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp") {
# Goofy variable value because nginx doesn't allow for checking multiple
# conditions in an `if` block.
set $needsCrawlerRedirect 'true $noJs';
}
# To avoid a redirect loop, we only redirect if it's not already on the no-js
# request path.
if ($needsCrawlerRedirect = 'true false') {
return 302 $scheme://$http_host/api/$path?javascript=false;
}
}