后端服务器地址:192.168.3.18
反向代理服务器地址:192.168.3.28
#192.168.3.18 nginx配置
[root@localhost nginx]# vi nginx.conf
user root;
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
root /root/nginx/a;
location /lile {
root /root/nginx;
}
}
}
~
mkdir -p /root/nginx/{a,b}
echo "aaaaaaaa" >> /root/nginx/a/index.html
echo "bbbbbbbbbbbbbbbbb" >> /root/nginx/b/index.html
#192.168.3.28 nginx配置
[root@localhost nginx]# vi nginx.conf
user root;
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://192.168.3.18;
}
}
}
启动两台主机nginx
访问代理服务器192.168.3.28
访问代理服务器192.168.3.28/lile