我正在尝试使用反向代理添加 SSL 证书在我的域的子目录上提供自托管的 sourcegraph 服务器。
目标是让http://example.org/source为 sourcegraph 服务器提供服务
我的重写和反向代理如下所示:
location /source {
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-Scheme $scheme;
rewrite ^/source/?(.*) /$1 break;
proxy_pass http://localhost:8108;
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,在调用http://example.org/source 时,我被重定向到http://example.org/sign-in?returnTo=%2F
有没有办法将 sourcegraph 的响应重写到正确的子目录?
另外,我可以在哪里调试重写指令?我想遵循它所做的更改以更好地理解它。
- 编辑:
我知道我的方法使用重写可能是错误的,我现在正在尝试 sub_filter 模块。
我使用 tcpdump 捕获了 sourcegraph 的响应并使用 wireshark 进行了分析,所以我在:
GET /sourcegraph/ HTTP/1.0
Host: 127.0.0.1:8108
Connection: close
Upgrade-Insecure-Requests: 1
DNT: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 …Run Code Online (Sandbox Code Playgroud)