当然,我不是第一个尝试从 为域提供服务example.com
的人example.net/bbb
,但我还没有找到解决方案。
我的 NGINX 配置遵循指导方针,看起来像这样:
server {
listen 80;
server_name example.net;
root /path/to/aaa;
location /bbb/ {
proxy_pass http://example.com/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.(svg|ttf|js|css|svgz|eot|otf|woff|jpg|jpeg|gif|png|ico)$ {
access_log off;
log_not_found off;
expires max;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以设法渲染example.com
in的根,example.net/bbb
但是:
example.net/bbb/some/path
预期和不工作index.html
的example.net
呈现。
中的任何资产example.com/assets
都会给出 404,因为浏览器会查找example.net/assets
. 如果我能在不到处放置绝对路径的情况下解决这个问题,那就太好了。