我有以下 nginx 配置:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location /git {
proxy_pass http://134.103.176.101:10080;
include proxy_params;
}
}
134.103.176.101 是我托管 Gitlab 的第二台服务器。因此当我上网时http://server1/git我得到了我的 gitlab。
问题是,所有 .png、.ttf 和 .woff 文件都找不到。这是因为他突然从路径中删除了 /git/:http://server1/assets/SourceSansPro-Regular-60f619fe2b3b48b193b9047abd7f8872.ttf Failed to load resource: the server
但是我在 Gitlab 安装中已将 GITLAB_RELATIVE_URL_ROOT 设置为 /git/。
为什么会发生这种情况?我如何获取这些图像?
谢谢! :)
编辑:我找到了一种解决方法,即重写丢失的请求
#Rewrites the request, extracting a fragment of the file name and using a remote server.
location @fetchFromRemote {
rewrite ^/assets/(.*)$ server1/git/assets/$1 redirect;
}
#Will try to see if we have the file in this server, is not will use fetchFromRemote
location ~ ^/assets/.*(png|jpg|jpeg|gif|ico|swf|ttf|woff|woff2)$ {
try_files $uri @fetchFromRemote;
}
这对我有用但不能解决问题本身!