Files
Work-configuration-file/nginx/代码仓库git.deeplink.media.conf
2025-10-07 15:58:15 +08:00

105 lines
3.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

server {
listen 443 ssl;
server_name git.deeplink.media;
ssl_certificate /data/tengine/conf/certificate/git.deeplink.media_bundle.crt;
ssl_certificate_key /data/tengine/conf/certificate/git.deeplink.media.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location ~ ^/go/([^/]+)(\?.*)?$ {
if ($arg_go-get) {
add_header Content-Type text/html;
return 200 "<html><head>
<meta name=\"go-import\" content=\"git.deeplink.media/go/$1 git https://git.deeplink.media/go/$1.git\">
</head><body>Go module redirect for $1</body></html>";
}
}
location / {
proxy_pass http://172.24.16.20:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_http_version 1.1;
proxy_set_header Connection "";
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always;
if ($request_method = OPTIONS ) {
return 204;
}
}
}
# 可选HTTP 自动跳转到 HTTPS
server {
listen 80;
server_name git.deeplink.media;
return 301 https://$host$request_uri;
}
# =============================
server {
listen 443 ssl;
server_name git.deeplink.media;
ssl_certificate /data/tengine/conf/certificate/git.deeplink.media_bundle.crt;
ssl_certificate_key /data/tengine/conf/certificate/git.deeplink.media.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# Go module 元信息
location ~ ^/go/(.+)$ {
if ($arg_go-get) {
add_header Content-Type text/html;
return 200 "<html><head>
<meta name=\"go-import\" content=\"git.deeplink.media/go/$1 git https://git.deeplink.media/$1.git\">
</head><body>Go module redirect for $1</body></html>";
}
# 如果不是 go-get 请求,直接反代到 GitLab (浏览器访问时能进仓库)
proxy_pass http://172.24.16.20/go/$1;
proxy_set_header Host 172.24.16.20;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 兜底配置,访问首页直接进 GitLab
location / {
proxy_pass http://172.24.16.20;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# HTTP 自动跳转 HTTPS
server {
listen 80;
server_name git.deeplink.media;
return 301 https://$host$request_uri;
}