fix go vanity urls

This commit is contained in:
Jeff 2020-07-02 15:26:02 +08:00
parent cfe32d5be2
commit b8f72a640b
No known key found for this signature in database
GPG Key ID: 87272103ED9C5218
2 changed files with 29 additions and 0 deletions

View File

@ -1,2 +1,3 @@
FROM nginx:alpine FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY public/ /usr/share/nginx/html/ COPY public/ /usr/share/nginx/html/

28
nginx.conf Normal file
View File

@ -0,0 +1,28 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
location ~ /([A-Za-z0-9_-]+)(/[A-Za-z0-9_.-]+)*$ {
if ($args = "go-get=1") {
return 200 '<html><head>\n\t<meta name="go-import" content="$host/$1 git https://github.com/kubesphere/$1">\n\t<meta name="go-source" content="$host/$1 https://github.com/kubesphere/$1 https://github.com/kubesphere/$1/tree/master/{/dir} https://github.com/kubesphere/$1/blob/master/{/dir}/{/file}#L{/line}">\n</head></html>\n';
}
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}