通过nginx转发解决:
server{
listen 80;
listen 443 ssl;
server_name gitlab.data-spark.cn;
if ($args ~* "^go-get=1") {
set $condition goget;
}
if ($uri ~ ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/.*$) {
set $condition "${condition}path";
}
if ($condition = gogetpath) {
return 200 "<!DOCTYPE html><html><head><meta content='gitlab.data-spark.cn/$1/$2 git http://gitlab.data-spark.cn/$1/$2.git' name='go-import'></head></html>";
}
ssl on;
ssl_certificate /etc/nginx/conf.d/ssl/gitlab.data-spark.cn_bundle.crt;
ssl_certificate_key /etc/nginx/conf.d/ssl/gitlab.data-spark.cn.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
# avoid ssl stripping
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
location / {
proxy_pass http://localhost:18080/;
}
error_page 497 https://$host$uri?$args;
}
加入了
if ($args ~* "^go-get=1") {
set $condition goget;
}
if ($uri ~ ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/.*$) {
set $condition "${condition}path";
}
if ($condition = gogetpath) {
return 200 "<!DOCTYPE html><html><head><meta content='your.domain.com/$1/$2 git http://your.domain.com/$1/$2.git' name='go-import'></head></html>";
}