反向代理apache等http資源 配置解釋:
反向代理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請求頭