大家好~
我的nginx版本是:代理机 1.10.1,被代理机 1.5.13
先看配置,代理机:
http {
proxy_redirect off;
proxy_buffers 6 512k;
proxy_connect_timeout 5s;
proxy_read_timeout 30s;
proxy_send_timeout 30s;
# proxy_method 'GET,POST,HEAD';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include conf.enabled/*.conf;
}
upstream abc {
server 10.1.10.16:80 max_fails=2 fail_timeout=1s;
}
server
{
listen 80;
listen 443 ssl;
server_name www.abc.com;
access_log logs/www.abc.com.access.log;
location / {
proxy_pass http://abc;
proxy_set_header SCHEME $scheme;
}
}
被代理机:
server {
listen 80;
server_name www.abc.com;
root /data/web/www.abc.com/web;
location / {
index index.php index.htm index.html;
}
location /act/ {
rewrite ^/act/(\w+)/(\w+)/$ /do.php?action="" last;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
目的是想让http请求时php输出http静态资源url,https请求时php输出https静态资源url,
所以我在代理机配置里加了 proxy_set_header SCHEME $scheme;然后php接收$_SERVER['HTTP_SCHEME']做处理
但是出现了别的异常,就是$_SERVER['HTTP_HOST']的值发生变化了,变成了abc,而不是
www.abc.com, 原来没问题啊,想到可能是新加的proxy_set_header SCHEME $scheme;影响的,注释掉后恢复正常,
可是我没有覆盖http段设置的proxy_set_header Host $host;啊,出现异常好像是proxy_set_header Host $host;被重置为默认值了,
为什么呢?这是bug吧
多谢各位请帮忙看下~