grace.myexample.com
我正在尝试使用 nginx创建一个子域(出于这个问题的目的:) 。
配置如下:
server {
listen 10.10.185.163:80;
server_name grace.myexample.com;
server_name www.grace.myexample.com;
server_name ipv4.grace.myexample.com;
client_max_body_size 128m;
location / { # IPv6 isn't supported in proxy_pass yet.
proxy_pass http://10.10.185.163:7080;
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-Accel-Internal /internal-nginx-static-location;
access_log off;
}
location /internal-nginx-static-location/ {
alias /var/www/vhosts/example.com/subdomains/grace/;
access_log /var/www/vhosts/grace.example.com/statistics/logs/proxy_access_log;
add_header X-Powered-By PleskLin;
internal;
}
}
当我进入我的子域时,它尝试从根域的 httpdocs 加载文件(例如/var/www/vhosts/example.com/httpdocs
)
答案1
鉴于您的上游服务器将其送回(在这里,您将在发送的请求消息中设置标头通过 nginx相关的上游服务器),这个:
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
应该 :
proxy_set_header X-Accel-Redirect /internal-nginx-static-location;
看文档引用上游中存在的特殊标头,由 nginx 解释回复信息。