简单明了的nginx配置请求转发以及负载均衡xml
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 20m;
upstream test_server {
server localhost:8083 weight=5;
server localhost:8084 weight=5;
}
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /api/ {
rewrite ^.+api/?(.*)$ /$1 break;
proxy_pass http://test_server/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}