Skip to content

Commit

Permalink
fix go vanity urls
Browse files Browse the repository at this point in the history
  • Loading branch information
zryfish committed Jul 2, 2020
1 parent cfe32d5 commit b8f72a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM nginx:alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY public/ /usr/share/nginx/html/
28 changes: 28 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}

}

0 comments on commit b8f72a6

Please sign in to comment.