反向代理apache等http资源
## Basic reverse proxy server ##
upstream apachephp{
server 127.0.0.1:8560; #php5.6
server 127.0.0.1:8540; #php5.4
server 127.0.0.1:8530; #php5.3
server 127.0.0.1:8520; #php5.2
}
server {
listen 8500;
server_name _;
root html;
index index.php;
## send request back to apache ##
location / {
proxy_pass http://apachephp;
#Proxy Settings
proxy_redirect off;
#proxy_set_header Host $host;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
配置解释:
$host、$http_host和$remote_addr都均为nginx导出变量,可以再配置文件中直接使用。
如果Host请求头部没有出现在请求头中,则$http_host值为空。
$host值为主域名
$http_host为当前http请求头