我有一个小的静态子站点,例如www.example.com/foo/
,我使用以下nginx配置:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 3600;
proxy_pass http://example-site/;
}
location /foo {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 3600;
proxy_pass http://example-web-foo/;
}
}
但是,当我在站点中使用一些基于根的URI时,例如/assets/css/style.css
,它会转换为https://example.com/assets/css/style.css
,而不是https://example.com/foo/assets/css/style.css
。
有没有办法在代理中指定根目录?
1条答案
按热度按时间gkl3eglg1#
我认为你可以通过使用
proxy_set_header
指令来编辑X-Forwarded-URI
头来指定代理中的根!看看这个